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
CoordinatedLeaseConfig
CoordinatedPendingTrigger
CoordinatedRuntimeState
CronSchedule
ExecutionGuardError
ExecutionLease
ExecutionSlot
GuardedRunner
InMemoryStateStore
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.
RunContext
RunRecord
Scheduler
SchedulerConfig
SchedulerHandle
SchedulerReport
StoreError
Task
TaskContext
TaskJoinError
TimeWindowSegment
ValkeyCoordinatedStateStore
ValkeyExecutionGuard
ValkeyLeaseConfig
ValkeyStateStore

Enums§

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

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.