Expand description
Async scheduling for a single logical job at a time.
The scheduler decides when to trigger work and persists the resulting job
state through a StateStore. Domain-specific retry, idempotency, and
cursor management remain in the caller.
Key semantics:
Schedule::AtTimeswaits until each planned timestamp and treats an empty list as a no-op schedule.Schedule::Intervalschedules the first run atnow + interval.Schedule::Cronevaluates a standard 5-field cron expression inSchedulerConfig::timezone.Job::with_max_runsapplies to every schedule kind;0exits without running.SchedulerConfig::timezoneis forwarded throughRunContext, drivesSchedule::Cronevaluation, and does not rewrite absoluteSchedule::AtTimesvalues.- Restarts resume by
job_idfrom the savedJobState::next_run_at. - Dependency injection here means passing an explicit
depsvalue when the job is constructed. The scheduler does not auto-resolve parameters.
use std::time::Duration;
use scheduler::{InMemoryStateStore, Job, Schedule, Scheduler, SchedulerConfig, Task};
let runtime = tokio::runtime::Runtime::new().unwrap();
runtime.block_on(async {
let scheduler = Scheduler::new(SchedulerConfig::default(), InMemoryStateStore::new());
let job = Job::without_deps(
"doc-simple",
Schedule::Interval(Duration::from_millis(1)),
Task::from_async(|_| async { Ok(()) }),
)
.with_max_runs(1);
let report = scheduler.run(job).await.unwrap();
assert_eq!(report.history.len(), 1);
});Structs§
- Cron
Schedule - Execution
Guard Error - Execution
Lease - Execution
Slot - InMemory
State Store - Invalid
JobError - Job
- JobState
- LogObserver
- Noop
Execution Guard - Noop
Observer - Resilient
State Store - Wraps a primary store with an in-process mirror that takes over after connection-class failures.
- RunContext
- RunRecord
- Scheduler
- Scheduler
Config - Scheduler
Handle - Scheduler
Report - Store
Error - Task
- Task
Context - Task
Join Error - Valkey
Execution Guard - Valkey
Lease Config - Valkey
State Store
Enums§
- Execution
Guard Acquire - Execution
Guard Error Kind - Execution
Guard Renewal - Invalid
JobKind - Missed
RunPolicy - Overlap
Policy - RunStatus
- Schedule
- Scheduler
Error - Scheduler
Event - Scheduler
Stop Reason - State
Load Source - Store
Error Kind - Store
Event - Store
Operation - Task
Join Error Kind - Terminal
State Policy
Traits§
- Execution
Guard - Resilient
Store Error - Classifies store errors that should trigger a one-way downgrade to the in-process mirror store.
- Scheduler
Observer - State
Store