pub fn batch<Kind>(jobs: impl IntoBatchJobs<Kind>) -> PendingBatchExpand description
Dispatch jobs as a batch and call its callbacks once they’ve all run.
Await the returned PendingBatch to dispatch every one of jobs at once. Once they’ve all
run, the worker calls the batch’s then,
catch, and finally
callbacks. jobs is a job or a chain, a tuple of jobs and chains of any
types, or an iterable of jobs or chains of one type. This function consumes and encodes an
iterable immediately.
Awaiting returns the batch’s BatchId, which you pass to find_batch to read the batch.
Each job of the batch can read the ID with Attempt::batch_id, add jobs to the batch with
Attempt::add_to_batch, and cancel the batch with Attempt::cancel_batch. A batch that
you pass to PendingChain::then becomes a step of the chain.
§Errors
Awaiting fails when a job can’t be encoded, a job’s connection isn’t defined, the batches
tables can’t be written, or a job can’t be dispatched. A job that can’t be dispatched also
cancels the batch. On the sync connection, each job runs as soon as it’s dispatched, and the
worker reports the jobs’ errors rather than returning them.
§Panics
Awaiting panics outside a request, a command, or an
Application::scope.