pub trait SchedulerPersistence:
Send
+ Sync
+ Debug {
// Required methods
fn record_started(
&self,
id: &QName,
started_at: SystemTime,
) -> Result<(), SchedulerPersistenceError>;
fn record_finished(
&self,
id: &QName,
finished_at: SystemTime,
success: bool,
) -> Result<(), SchedulerPersistenceError>;
fn cancel(&self, id: &QName) -> Result<(), SchedulerPersistenceError>;
fn load_all(
&self,
) -> Result<Vec<SchedulerJobRecord>, SchedulerPersistenceError>;
// Provided methods
fn record_scheduled(
&self,
_id: &QName,
_schedule: &Schedule,
) -> Result<(), SchedulerPersistenceError> { ... }
fn flush_checkpoint(&self) -> Result<(), SchedulerPersistenceError> { ... }
}Expand description
Persistence backend for Scheduler job state.
Mirrors the meta-plugin’s Persistence trait in shape but scoped
to scheduler records. The Tokio driver (crates/uni/src/scheduler.rs)
invokes record_started / record_finished / cancel on each
lifecycle transition; on startup the driver calls load_all and
re-registers persisted jobs (followed by
Scheduler::requeue_orphaned_runs for any that were Running
at the previous shutdown / crash).
Two impls ship in-tree:
MemoryPersistence— no-op tests + as the default before the host wires a system-label backend.SystemLabelPersistence(inuni-query, lands with the M9 cutover): round-trips throughuni_system.background_jobsvia the write-enabledQueryProcedureHost::execute_inner_query.
Required Methods§
Sourcefn record_started(
&self,
id: &QName,
started_at: SystemTime,
) -> Result<(), SchedulerPersistenceError>
fn record_started( &self, id: &QName, started_at: SystemTime, ) -> Result<(), SchedulerPersistenceError>
Persist a job’s transition into a new run.
§Errors
Returns SchedulerPersistenceError on backend failure.
Sourcefn record_finished(
&self,
id: &QName,
finished_at: SystemTime,
success: bool,
) -> Result<(), SchedulerPersistenceError>
fn record_finished( &self, id: &QName, finished_at: SystemTime, success: bool, ) -> Result<(), SchedulerPersistenceError>
Persist the outcome of a finished run.
§Errors
Returns SchedulerPersistenceError on backend failure.
Sourcefn load_all(&self) -> Result<Vec<SchedulerJobRecord>, SchedulerPersistenceError>
fn load_all(&self) -> Result<Vec<SchedulerJobRecord>, SchedulerPersistenceError>
Reload all known job records (used on host startup to restore scheduler state across restart). Order is unspecified — the driver re-registers them in any order.
§Errors
Returns SchedulerPersistenceError on backend failure.
Provided Methods§
Sourcefn record_scheduled(
&self,
_id: &QName,
_schedule: &Schedule,
) -> Result<(), SchedulerPersistenceError>
fn record_scheduled( &self, _id: &QName, _schedule: &Schedule, ) -> Result<(), SchedulerPersistenceError>
Persist a job’s schedule at registration time.
Called by the host wrapper (e.g. SchedulerHost) whenever a
caller invokes add_scheduled_job, so the schedule kind
(Periodic / Cron / Once / Manual) survives restart and
can be round-tripped through Self::load_all. The default
no-op suits in-memory backends and pre-existing impls that do
not need durability.
§Errors
Returns SchedulerPersistenceError on backend failure.
Sourcefn flush_checkpoint(&self) -> Result<(), SchedulerPersistenceError>
fn flush_checkpoint(&self) -> Result<(), SchedulerPersistenceError>
Force any in-memory buffers to durable storage.
Invoked by uni.periodic.commit so operators can drive a
synchronous checkpoint flush. Backends that write through on
every event (the default for the system-label backend) leave
this as the default no-op; buffered backends override.
§Errors
Returns SchedulerPersistenceError on backend failure.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".