pub struct MaintenanceChain { /* private fields */ }Expand description
The maintenance chain’s consumer side — the schedule registration + the runner, the worker’s claim loop, the leader TTL lock, the sweep dispatch, and the supervised halves the wave-6 gate booked the chain to own (the wake runner’s restart on both stop shapes; the reconcile tick’s driving).
Contract stamp: substrate.md §GC; ADR-019 §6.
Constructed from the assembly’s pieces: the engine handle (the
same one the reactor rides), the alkblobs store (the
sweep() leg’s target — the liveness source itself is
registered at the composition construction, e.g.
crate::liveness::RefClosure::register; a sweep dispatched
without one aborts with NoLivenessSources — the report carries
it), the reactor + the applied watermark (the supervision +
reconcile legs), the shared through-store pack cache when the
assembly serves packs through-store, and the tuning datums.
The wave-8 single composition entry unifies the construction;
this is the per-piece constructor (the recorded interpretation —
substrate/w6-scaffold-manifest’s shape).
Implementations§
Source§impl MaintenanceChain
impl MaintenanceChain
Sourcepub fn new(
store: Arc<dyn Store>,
blobs: Arc<BlobStore>,
reactor: Arc<Reactor>,
applied: Arc<AppliedWatermark>,
packs: Option<Arc<PackCache>>,
opts: MaintenanceOpts,
) -> Self
pub fn new( store: Arc<dyn Store>, blobs: Arc<BlobStore>, reactor: Arc<Reactor>, applied: Arc<AppliedWatermark>, packs: Option<Arc<PackCache>>, opts: MaintenanceOpts, ) -> Self
The chain over the assembly’s pieces. packs is the
through-store pack cache when the assembly serves packs
through-store (None on the direct shape — the
pack-housekeeping job then acks with nothing to release).
Sourcepub fn store(&self) -> &Arc<dyn Store> ⓘ
pub fn store(&self) -> &Arc<dyn Store> ⓘ
The engine handle (the schedule, the queue and the lock ride it — the same handle the reactor rides).
Sourcepub fn opts(&self) -> &MaintenanceOpts
pub fn opts(&self) -> &MaintenanceOpts
The chain’s tuning datums.
Sourcepub async fn register_sweep_schedule(&self, spec: &str) -> Result<Schedule>
pub async fn register_sweep_schedule(&self, spec: &str) -> Result<Schedule>
The schedule registration — upsert SWEEP_SCHEDULE
firing into MAINTENANCE_QUEUE with the
MaintenanceJob::Sweep payload (the worker’s dispatch
vocabulary). Idempotent by upsert; the spec is
schedule()’s v1 grammar.
Sourcepub async fn run(
&self,
worker_id: &str,
stop: StopToken,
on_event: impl FnMut(WorkerEvent) + Send,
) -> Result<()>
pub async fn run( &self, worker_id: &str, stop: StopToken, on_event: impl FnMut(WorkerEvent) + Send, ) -> Result<()>
The chain’s run — registration, the supervised legs, the reconciliation tick, and the worker’s claim loop, all under one stop token:
- the sweep schedule is upserted first (loud — a chain without its schedule never fires);
- the scheduler runner runs under supervision — respawned
on
Err(LeadershipLost); any other stop (the alkstore contract’s closed-store/storage-failure posture) is propagated: the chain returns it. The legs wind down via the chain’s own internal token — cancelled on every return (the wave-7 gate’s O-b disposition: the wake leg’s restart loop exits on it without waiting out the caller’s token; the caller’s stop token is never cancelled by the chain). - the wake runner is supervised — restarted on both stop
shapes (the N-b rider: the runner’s
Ok(())on arecv_timeout/listenfailure is the collapsed stop; the restart’s backoff isMaintenanceOpts::wake_retry_backoff, the recovery a freshlisten); - the reconcile tick drives one
Reactor::reconcilepass everyMaintenanceOpts::reconcile_tick(fail-soft — a failed pass leaves the previous snapshot serving); - the worker claim loop drains
MAINTENANCE_QUEUEon every poll tick (claim until no work, dispatch on theMaintenanceJobvocabulary, observation throughon_event).
Returns Ok(()) on a cancelled stop token (legs joined) and
Err(alkstore::Error) on a scheduler-leg substrate failure.