bkeepers/qu — pull request #96 by grantr (2014-10-07 16:07:55+00:00)
Title: Batch jobs

This is a WIP on batch processing (https://github.com/bkeepers/qu/issues/93).

Adds a `BatchJob` class that takes payload arrays. `BatchJob` implements `each` for iterating through each payload's args. `BatchJob` can also take single payloads, in which case it wraps the payload in an array making a batch of 1. Default batch size is 1, but jobs can change it like they change queue name.

```
class SimpleBatchJob < Qu::BatchJob
batch_size 50

def perform
request = []
each do |arg1, arg2|
request << [arg1, arg2]
end
submit_request(request)
end

def submit_request(request)
end
end
```

If this is a direction that works for other people, I'll keep working on other aspects like backend support and failure handling.

/cc @bkeepers @jnunemaker @mauricio