Skip to main content

WorkerSupervisor

Struct WorkerSupervisor 

Source
pub struct WorkerSupervisor { /* private fields */ }
Expand description

Server-owned supervision of the managed worker fleet.

Implementations§

Source§

impl WorkerSupervisor

Source

pub fn new( store: Arc<dyn WorkerDeploymentStore>, publisher: ClusterEventPublisher, ) -> Self

Build an UNCOMMISSIONED supervisor over the durable deployment store, publishing desired-state changes onto the deployment-global cluster channel.

The publisher lives HERE — not in the transports — so every desired-state write the supervisor makes (Self::start, Self::stop, and Self::restart through them) reaches the console’s live feed identically whichever transport asked, exactly as the worker-deployment desired-state endpoint publishes its own writes.

Nothing is supervised until Self::commission installs an operator policy: construction is not commissioning, so a server that boots without the config section never spawns anything.

Source

pub fn commission( &self, policy: SupervisionPolicy, executable: ManagedExecutable, ) -> bool

Install the operator’s supervision policy and the executable a builtin deployment means on this server.

Returns false when a commission was already installed, in which case the existing one stands: the restart discipline of a running fleet is not something a later caller gets to swap out underneath it.

Source

pub fn policy(&self) -> Option<SupervisionPolicy>

The installed policy, if this server has one.

Source

pub fn is_commissioned(&self) -> bool

Whether an operator commission is installed.

Source

pub async fn start( &self, name: &str, ) -> Result<ManagedWorkerStatus, SupervisionError>

Start (or adopt) supervision of one deployment, recording the intent durably first. A durable desired-state flip is published onto the cluster channel, so the console’s live feed sees it whichever transport asked.

Idempotent: a deployment already being supervised is reported as it is, without a second process (and, already desiring Running, without a second event).

§Errors

Returns SupervisionError::NotCommissioned when no policy is installed — carrying the remedy — SupervisionError::UnknownDeployment for a name with no durable record, and SupervisionError::Store when the record cannot be read or the intent cannot be written.

Source

pub async fn stop( &self, name: &str, ) -> Result<ManagedWorkerStatus, SupervisionError>

Stop one deployment and record the intent durably. The durable desired-state write is published onto the cluster channel, so the console’s live feed sees it whichever transport asked.

The returned status is written only once the process group has been probed empty; a group that survives the termination ladder produces SupervisionError::StopIncomplete instead, so a caller can never read “stopped” off bookkeeping alone.

§Errors

Returns SupervisionError::UnknownDeployment for an absent record, SupervisionError::Store when the intent cannot be written, SupervisionError::StopIncomplete when the group cannot be proven empty, and SupervisionError::TaskLost when the supervision task ended abnormally.

Source

pub async fn restart( &self, name: &str, ) -> Result<ManagedWorkerStatus, SupervisionError>

Stop and start one deployment, leaving desired state at Running.

Publishes exactly what it durably writes: a restart of an already-Running deployment changes no desired state and emits no desired-state event; one that flips it inherits Self::start’s.

§Errors

Returns the same failures as Self::stop and Self::start.

Source

pub async fn reconcile(&self) -> Result<usize, SupervisionError>

Bring the fleet to its durable desired state.

Called at boot and safe to call again: deployments already supervised are left alone. Returns the number of deployments now supervised.

§Errors

Returns SupervisionError::NotCommissioned when no policy is installed, and SupervisionError::Store when the durable listing cannot be read.

Source

pub async fn report(&self) -> Result<ManagedWorkerReport, SupervisionError>

Join durable intent with live supervision for every deployment.

§Errors

Returns SupervisionError::Store when the durable listing cannot be read, and SupervisionError::StatePoisoned when a status cell was poisoned by a panicking holder.

Source

pub async fn shutdown(&self) -> Vec<SupervisionError>

Stop every supervised instance, for server shutdown.

Durable desired state is deliberately NOT changed: a server going down is not an operator asking for the fleet to stay down, and the next boot reconciles it back up. Returns one failure per instance that could not be proven stopped — an empty vector is the proof that no worker was orphaned.

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> 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> 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, <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