Durable.Scheduler (Durable v2.0.2)
View SourceGenServer that polls for due scheduled workflows and triggers them.
This module runs as part of the Durable supervision tree and:
- Polls every 60 seconds for due schedules
- Claims each fire with one conditional update, for multi-node safety
- Starts workflows via the normal queue system
- Updates last_run_at and next_run_at as it claims each fire
Multi-Node Safety
When running multiple Durable instances (e.g., multiple app nodes),
only one node starts each fire of a schedule. Each node that sees a schedule
due tries to move its next_run_at on from the value it read, and only the
one whose update matched a row starts the run. The update and the start
commit together, so a node that dies between them leaves the fire to the next.
Configuration
The scheduler is automatically started when Durable starts. No additional configuration is required.
Summary
Functions
Manually triggers a check for due schedules.
Returns a specification to start this module under a supervisor.
Returns the process name for a given Durable instance.
Starts the scheduler process.
Returns the current state of the scheduler for debugging.
Functions
@spec check_schedules(atom()) :: :ok
Manually triggers a check for due schedules.
Returns a specification to start this module under a supervisor.
See Supervisor.
Returns the process name for a given Durable instance.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the scheduler process.
Options
:config- The Durable configuration (required):interval- Poll interval in milliseconds (default: 60_000):scheduled_modules- List of modules to register on startup
Returns the current state of the scheduler for debugging.