Files
Oxicloud/src/infrastructure/scheduler/mod.rs
T

41 lines
1.7 KiB
Rust
Raw Normal View History

2026-07-27 22:03:05 +02:00
//! Periodic job scheduler (Part 1 of the job-registry plan).
//!
//! In-memory registration + one-supervisor-task dispatch. Fires
//! registered [`JobHandler`] implementations at their configured
//! intervals with panic containment, timeout enforcement, and
//! same-name exclusivity.
//!
//! # For future implementors
//!
//! - **You write a `JobHandler`.** Implement [`JobHandler::name`] +
//! [`JobHandler::run`] on your service. Nothing else. See
//! [`handler`] for the guidance doc-comment.
//! - **DI wires the registration.** In `common/di.rs` (or wherever the
//! composition root lives), build an `Arc<JobRegistry>` once, register
//! every service that opts in, then call [`SchedulerEngine::start`].
//! - **Should this loop actually be a scheduler job?** See the migration
//! criterion in `docs/plan/job-registry.md` — the primary question
//! is "would an operator plausibly trigger this manually?". Continuous
//! drains and event-reactive workers stay as their own loops.
//!
//! Part 2 (recoverable-run engine, DB-backed cursor + resume) is
//! designed but not yet implemented. When it lands it will slot in
//! as a sibling module without changing anything here.
mod engine;
mod handler;
2026-07-28 22:22:46 +02:00
mod pg_job_store;
mod recoverable;
2026-07-27 22:03:05 +02:00
mod registry;
mod types;
pub use engine::SchedulerEngine;
pub use handler::JobHandler;
2026-07-28 22:22:46 +02:00
pub use pg_job_store::{PgJobStore, PgJobStoreProvider};
pub use recoverable::{
JobStore, JobStoreProvider, OpenedRun, RecoverableAdapter, RecoverableJobHandler, RunOutcome,
RunStatus, RunSummary, run_or_resume,
2026-07-28 22:22:46 +02:00
};
2026-07-27 23:23:23 +02:00
pub use registry::{JobEntry, JobRegistry, JobSummary, RegisterError};
pub use types::{ErrCause, JobOutcome, JobRunArgs};