Skip to main content

WarmSwap

Struct WarmSwap 

Source
pub struct WarmSwap<G, D, L, R> { /* private fields */ }
Expand description

The warm drain-swap-resume orchestrator over its four control seams.

Holds the admission gate, the drain, the lease control, and the resume seam. WarmSwap::run drives the fixed sequence, delegating the swap core (verify → apply → health check → auto-rollback) to a Stager whose Activator is a process or image swap. The orchestrator adds only the ordering: close before drain, drain before release, release before swap, swap before re-acquire, re-acquire before resume.

Implementations§

Source§

impl<G, D, L, R> WarmSwap<G, D, L, R>
where G: AdmissionGate, D: Drain, L: LeaseControl, R: Resume,

Source

pub const fn new(gate: G, drain: D, lease: L, resume: R) -> Self

Build a warm-swap orchestrator over its four control seams.

Source

pub fn run<S, V, A, H>( &self, verdict: &Compatibility, stager: &mut Stager<S, V, A, H>, release: &ReleaseId, ) -> Result<WarmSwapReport, WarmSwapError>

Run the warm drain-swap-resume for a Warm-classified release.

The sequence is fixed and its ordering is the invariant:

  1. gate on the classifier — refuse anything but Compatibility::Warm before touching any seam;
  2. close admission, so no new turn is admitted while draining;
  3. drain to a committed checkpoint — in-flight turns and paused approvals reach their turn_complete marker, captured as a Checkpoint, while the lease is still held;
  4. release the lease;
  5. swap via the Stager — verify the new binary’s signature, apply the pointer flip, health-check, and auto-roll-back on failure;
  6. re-acquire the lease — always, on whichever binary is now live, so the conversation is never left drained-but-dead;
  7. resume from the checkpoint, re-driving paused approvals, and verify it restarted from exactly the drained turn.

The lease re-acquire in step 6 runs even when the swap rolled back or its signature was refused, so a failed swap surfaces its error only after the conversation is back under a held lease.

§Errors

Returns WarmSwapError::NotWarm when verdict is not warm (nothing is drained or swapped); WarmSwapError::Admission or WarmSwapError::Drain when the pre-swap steps fail (the lease is still held); WarmSwapError::Lease when a release or re-acquire fails; WarmSwapError::Stage when the stager cannot verify or apply the swap (surfaced after the lease is re-acquired); and WarmSwapError::Resume or WarmSwapError::ResumeMismatch when resume fails or restarts from the wrong turn.

Auto Trait Implementations§

§

impl<G, D, L, R> Freeze for WarmSwap<G, D, L, R>
where G: Freeze, D: Freeze, L: Freeze, R: Freeze,

§

impl<G, D, L, R> RefUnwindSafe for WarmSwap<G, D, L, R>

§

impl<G, D, L, R> Send for WarmSwap<G, D, L, R>
where G: Send, D: Send, L: Send, R: Send,

§

impl<G, D, L, R> Sync for WarmSwap<G, D, L, R>
where G: Sync, D: Sync, L: Sync, R: Sync,

§

impl<G, D, L, R> Unpin for WarmSwap<G, D, L, R>
where G: Unpin, D: Unpin, L: Unpin, R: Unpin,

§

impl<G, D, L, R> UnsafeUnpin for WarmSwap<G, D, L, R>

§

impl<G, D, L, R> UnwindSafe for WarmSwap<G, D, L, R>

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> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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