T3.RPC.WorkQueue (T3 v0.3.0)

Copy Markdown View Source

Optional bounded, ordered, in-memory processing for reader chunks.

Supervise this process before the reader. :work is a function receiving an event and returning :ok; it runs in an isolated worker. enqueue/2 returns immediately after admission, so upstream ACK means accepted in memory, not processed or durable. A crash/kill of this queue can lose accepted work. Use a durable application queue inside the normal synchronous reader callback when processing must survive failures.

:capacity (default 32) counts the running event plus queued events. A full queue returns {:error, :busy}, which Reader understands for chunk callbacks: it retains that chunk and withholds its ACK until admission succeeds. Only one worker runs, preserving admission order. :work_timeout defaults to 30 seconds. Worker failures/timeouts notify the required :owner PID or registered process as {:t3_work_queue, queue, {:failed, event}} and processing continues. Handle this notification explicitly if retries or reconciliation are required. Work is not retried automatically, because its side effects may already have occurred.

Status output omits work, queued data and callback closures.

Summary

Functions

Returns a specification to start this module under a supervisor.

Admit work without waiting for execution, or return {:error, :busy}.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

enqueue(server, event)

Admit work without waiting for execution, or return {:error, :busy}.

start_link(opts)