A single inference worker holding backend state.
Started only for models whose backend declares concurrency: :exclusive. Shared backends run
in the calling process and never reach this module.
A worker does exactly one thing: call the backend. Cache lookups, input validation and the
preprocess/postprocess hooks all run in the caller before dispatch, because a worker slot
is the scarce resource — occupying one with an Ecto query while a GPU sits idle is the mistake
this design exists to prevent.
Deadlines
Requests carry an absolute monotonic deadline, and the worker checks it before invoking the backend. Work whose caller has already timed out is dropped rather than run.
That matters under overload. A GenServer.call timeout only abandons the caller's side; the
worker still grinds through the whole queue, every item arriving later than the last, and the
system never recovers. Checking the deadline at the front of the queue turns a death spiral
into load shedding.
Summary
Functions
Runs a batch prediction on worker, honouring deadline.
Returns a specification to start this module under a supervisor.
Runs a single prediction on worker, honouring deadline.
Types
Functions
@spec batch_predict(pid() | GenServer.name(), [term()], integer(), timeout()) :: {:ok, [term()], map()} | {:error, term()}
Runs a batch prediction on worker, honouring deadline.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec predict(pid() | GenServer.name(), term(), integer(), timeout()) :: {:ok, term(), map()} | {:error, term()}
Runs a single prediction on worker, honouring deadline.
Returns {:ok, result, measurements} so the caller can fold queue_duration and
inference_duration into its telemetry span — the worker is the only place that can measure
how long the request actually waited.