Anvil.Workers.TimeoutChecker (Anvil v0.1.1)

View Source

Background job worker that checks for timed-out assignments and requeues them.

This worker runs periodically (every 5 minutes via cron) to find assignments that have exceeded their deadline and transitions them from :reserved to :timed_out status, then requeues them for another labeler.

Configuration

Queue: :timeouts Max Attempts: 3 Priority: 1 (high priority)

Scheduled Execution

Configured in config.exs via Oban.Plugins.Cron:

{"*/5 * * * *", Anvil.Workers.TimeoutChecker}

Telemetry

Emits the following telemetry events:

  • [:anvil, :workers, :timeout_checker, :started] - Job execution started
  • [:anvil, :workers, :timeout_checker, :completed] - Job completed successfully
  • [:anvil, :workers, :timeout_checker, :failed] - Job failed

Summary

Functions

Handles a single timed-out assignment by marking it as timed_out and requeuing it.

Functions

handle_timeout(assignment)

@spec handle_timeout(Anvil.Schema.Assignment.t()) ::
  {:ok, :requeued} | {:error, term()}

Handles a single timed-out assignment by marking it as timed_out and requeuing it.