Durable.Wait.SleepWaker (Durable v0.1.0-rc)

View Source

Background worker that revives workflows whose sleep/1 or schedule_at/1 wait has elapsed.

When a step body calls sleep or schedule_at, the executor flips the workflow to :waiting and stamps scheduled_at. This worker periodically asks the queue adapter to flip any such row back to :pending once scheduled_at <= NOW(), so the queue poller can re-claim it. The adapter also merges a :__sleep_satisfied__ marker into the workflow's context so the step body's next sleep call returns immediately rather than re-throwing.

Polls every :sleep_waker_interval milliseconds (default 1_000) and wakes up to :sleep_waker_batch_size workflows per tick (default

  1. — both configurable via Durable.Config.

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts the sleep waker.

Manually triggers a sweep, returning {:ok, woken_count}.

Returns the process name for a given Durable instance.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

Starts the sleep waker.

Options

  • :config - The Durable config (required)
  • :interval - Override the config's :sleep_waker_interval (optional)
  • :batch_size - Override the config's :sleep_waker_batch_size (optional)

wake_now(durable_name \\ Durable)

Manually triggers a sweep, returning {:ok, woken_count}.

Useful in tests and operational tooling — the periodic timer keeps ticking independently.

worker_name(durable_name)

Returns the process name for a given Durable instance.