pub struct Stager<S, V, A, H> { /* private fields */ }Expand description
The apply substrate: stage → verify → apply → (commit | auto-rollback).
Holds the live version and the previous version behind it, plus the four
seams that touch the outside world. Stager::stage_and_apply drives the
whole sequence; Stager::live and Stager::previous expose the current
pointer state.
Implementations§
Source§impl<S, V, A, H> Stager<S, V, A, H>
impl<S, V, A, H> Stager<S, V, A, H>
Sourcepub const fn new(
source: S,
verifier: V,
activator: A,
health: H,
initial_live: ReleaseId,
) -> Self
pub const fn new( source: S, verifier: V, activator: A, health: H, initial_live: ReleaseId, ) -> Self
Build a stager over its four seams, starting from initial_live as the
version already serving.
Sourcepub const fn live(&self) -> &ReleaseId
pub const fn live(&self) -> &ReleaseId
The version currently serving — the committed live pointer.
Sourcepub const fn previous(&self) -> Option<&ReleaseId>
pub const fn previous(&self) -> Option<&ReleaseId>
The previous version, kept staged so a rollback is a pointer flip. None
until the first update commits.
Sourcepub fn stage_and_apply(
&mut self,
release: &ReleaseId,
) -> Result<Outcome, StageError>
pub fn stage_and_apply( &mut self, release: &ReleaseId, ) -> Result<Outcome, StageError>
Stage release, verify it, apply it, and commit or auto-roll-back on the
health check.
The sequence is fixed:
- download the release to a side location;
- verify its signature — an unverified bundle returns
StageError::Unverifiedwith the live pointer untouched; - flip the live pointer to the new version;
- run the health check — on
Health::Healthycommit and returnOutcome::Committed; onHealth::Unhealthyflip the pointer back to the previous version and returnOutcome::RolledBack.
The committed live pointer (Stager::live) only advances in step 4 on
a passed health check, so a refused or rolled-back attempt leaves the
stager exactly where it started.
§Errors
Returns StageError::Download if the source cannot stage the release,
StageError::Unverified if the signature does not verify, or
StageError::Activate if a pointer flip fails (applying the new
version, or — worse — flipping back during a rollback).
Auto Trait Implementations§
impl<S, V, A, H> Freeze for Stager<S, V, A, H>
impl<S, V, A, H> RefUnwindSafe for Stager<S, V, A, H>
impl<S, V, A, H> Send for Stager<S, V, A, H>
impl<S, V, A, H> Sync for Stager<S, V, A, H>
impl<S, V, A, H> Unpin for Stager<S, V, A, H>
impl<S, V, A, H> UnsafeUnpin for Stager<S, V, A, H>
impl<S, V, A, H> UnwindSafe for Stager<S, V, A, H>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request