feat(job-registry): add the job engine

This commit is contained in:
Edouard Vanbelle
2026-07-27 22:03:05 +02:00
parent 5e8d894a0c
commit 8bb62affc8
6 changed files with 847 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
//! 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;
mod registry;
mod types;
pub use engine::SchedulerEngine;
pub use handler::JobHandler;
pub use registry::{JobEntry, JobRegistry, RegisterError};
pub use types::{ErrCause, JobOutcome};