shigoto_stager (shigoto v1.9.10)

View Source

Latency accelerator for delayed jobs. On a short interval it finds queues with work due to run now (a job's scheduled_at has elapsed, including a failed job rescheduled after its backoff) and issues a pg_notify('shigoto_jobs_insert', Queue) so the existing notifier wakes the matching queue immediately instead of waiting up to poll_interval.

Uses pg_try_advisory_xact_lock so only one node stages in a multi-node deployment; the notification still reaches every node.

Started only when the notifier is configured. The per-queue polling fallback remains the correctness backstop; the stager only reduces latency, and fails soft on any database error so a transient fault never crashes the supervision tree.

Summary

Functions

Return the distinct queues with jobs that are due to run right now.

Run one staging pass synchronously (leader-gated). Fails soft. Mainly for testing.

Functions

due_queues(Pool)

-spec due_queues(atom()) -> {ok, [binary()]} | {error, term()}.

Return the distinct queues with jobs that are due to run right now.

stage_once()

-spec stage_once() -> ok.

Run one staging pass synchronously (leader-gated). Fails soft. Mainly for testing.