Method EnqueueBatchAsync
- Namespace
- Millrace
- Assembly
- Millrace.dll
EnqueueBatchAsync(JobBatch, CancellationToken)
Enqueues a batch in one round trip and one transaction, returning the effective ids positionally.
ValueTask<IReadOnlyList<JobId>> EnqueueBatchAsync(JobBatch batch, CancellationToken ct = default)
Parameters
batchJobBatchctCancellationToken
Returns
Examples
var batch = new JobBatch();
foreach (var id in orderIds)
{
batch.Enqueue<IEmailSender>(s => s.SendAsync(id));
}
await jobs.EnqueueBatchAsync(batch);
Remarks
All-or-nothing: every job lands or none does. A partially-enqueued fan-out is worse than none, because the caller cannot tell which half landed and retrying duplicates the rest.
Ids are returned by position, and a position whose idempotency key was already held returns the existing job's id rather than a new one — the same rule a single enqueue follows (§4.2.6).