Skip to main content

Crate scheduler

Crate scheduler 

Source
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:

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§

CoordinatedClaim
CoordinatedCompletion
CoordinatedLeaseConfig
CoordinatedPendingTrigger
CoordinatedRuntimeState
CronSchedule
ExecutionGuardError
ExecutionLease
ExecutionSlot
GroupedCronSchedule
Cron schedule that spreads members evenly inside a post-anchor window.
GroupedIntervalSchedule
Interval schedule that spreads members evenly across the interval.
GuardedRunner
InMemoryStateStore
IntervalWindow
Interval override for a matching time window.
InvalidJobError
Job
JobState
JobTimeWindow
LogObserver
NoopCoordinatedStateStore
NoopExecutionGuard
NoopObserver
ResilientStateStore
Wraps a primary store with an in-process mirror that takes over after connection-class failures and opportunistically writes dirty state back once the primary accepts commands again.
RunContext
RunRecord
Scheduler
SchedulerConfig
SchedulerHandle
SchedulerReport
StaggeredIntervalSchedule
Interval schedule with a stable phase derived from a seed.
StoreError
Task
TaskContext
TaskJoinError
TimeWindowSegment
TriggeredTaskContext
ValkeyCoordinatedStateStore
ValkeyExecutionGuard
ValkeyLeaseConfig
ValkeyRecoveryConfig
ValkeyStateStore
WindowedIntervalSchedule
Interval schedule with per-window frequencies.

Enums§

ExecutionGuardAcquire
ExecutionGuardErrorKind
ExecutionGuardEvent
ExecutionGuardRenewal
ExecutionGuardScope
GuardedRunResult
InvalidJobKind
MissedRunPolicy
OverlapPolicy
PauseScope
RunSkipReason
RunStatus
Schedule
SchedulerError
SchedulerEvent
SchedulerStopReason
StateLoadSource
StoreErrorKind
StoreEvent
StoreOperation
TaskJoinErrorKind
TerminalStatePolicy
TimeWindowAlignment
TriggerSource

Traits§

CoordinatedStateStore
ExecutionGuard
ResilientStoreError
Classifies store errors that should trigger a one-way downgrade to the in-process mirror store.
SchedulerObserver
StateStore

Type Aliases§

JobFuture
The boxed future returned by a scheduled job.
JobResult
The task return type used by scheduled jobs.