Skip to main content

MaintenanceChain

Struct MaintenanceChain 

Source
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

Source

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).

Source

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).

Source

pub fn blobs(&self) -> &Arc<BlobStore> ⓘ

The alkblobs store (the sweep dispatch’s target).

Source

pub fn opts(&self) -> &MaintenanceOpts

The chain’s tuning datums.

Source

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.

Source

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 a recv_timeout/listen failure is the collapsed stop; the restart’s backoff is MaintenanceOpts::wake_retry_backoff, the recovery a fresh listen);
  • the reconcile tick drives one Reactor::reconcile pass every MaintenanceOpts::reconcile_tick (fail-soft — a failed pass leaves the previous snapshot serving);
  • the worker claim loop drains MAINTENANCE_QUEUE on every poll tick (claim until no work, dispatch on the MaintenanceJob vocabulary, observation through on_event).

Returns Ok(()) on a cancelled stop token (legs joined) and Err(alkstore::Error) on a scheduler-leg substrate failure.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more