JoobQ.Batches (joobq_ex v0.8.0)

Copy Markdown View Source

JoobQ Pro batches: 1 to 1000 jobs created, filled and sealed in one call (JoobQ.create_batch/2, POST /sdk/batches), with callback jobs the gateway enqueues when the batch gets there: :on_failure at the first dead member, :on_complete once every member is counted, and :on_success then too when none is dead. A callback is written by the gateway only, exactly once, with "batch" => %{"id", "kind", "total", "succeeded", "failed"} in its payload. Without a Pro licence the gateway answers 402 (:pro_required).

A member or a callback is a job as JoobQ.enqueue_many/2 takes it: {queue, job_type}, {queue, job_type, payload} or {queue, job_type, payload, opts}. A member takes the options of JoobQ.Job but :unique_key and :unique_mode (a deduplicated member would never finish); a callback takes :context, :max_retries, :expires_ms and :timeout_ms only. Options of the batch: :description (at most 500 characters), :context (merged key by key into every member's and callback's own, whose keys win), :on_complete, :on_success, :on_failure.

Summary

Functions

The body of POST /sdk/batches; raises ArgumentError naming what is wrong, never a value.

The path of the batch id, a UUID (as the gateway makes them); raises ArgumentError for anything else.

Functions

body(jobs, opts)

@spec body([tuple()], keyword()) :: map()

The body of POST /sdk/batches; raises ArgumentError naming what is wrong, never a value.

path(id)

@spec path(String.t()) :: String.t()

The path of the batch id, a UUID (as the gateway makes them); raises ArgumentError for anything else.