Durable.Scheduler (Durable v0.1.0-rc)
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
- Uses
FOR UPDATE SKIP LOCKEDfor multi-node safety - Starts workflows via the normal queue system
- Updates last_run_at and next_run_at after each execution
Multi-Node Safety
When running multiple Durable instances (e.g., multiple app nodes),
only one node will execute each scheduled workflow. This is achieved
using PostgreSQL's FOR UPDATE SKIP LOCKED clause, which allows
each node to atomically claim schedules without conflicts.
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.