Skip to main content

Supervisor

Struct Supervisor 

Source
pub struct Supervisor<const N: usize, T: Topology<N> = Ordered<N, { shape::ALL }>> { /* private fields */ }
Expand description

Orchestrates a set of managed tasks across spawn / teardown / bring-up.

Owned by a single supervisor task. Concurrent access from other tasks goes through each TaskNode’s own atomic state, not the Supervisor struct.

Implementations§

Source§

impl<const N: usize, T: Topology<N>> Supervisor<N, T>

Source

pub async fn run_pools(&self, spawner: &Spawner) -> NodeFault

Drive all elastic pools forever, returning only on a fault.

Source§

impl<const N: usize, T: Topology<N>> Supervisor<N, T>

Source

pub const fn new(graph: &'static Graph<N, T>) -> Self

Create a supervisor from a statically-built graph.

Source

pub async fn start(&self, spawner: &Spawner) -> Result<(), NodeFault>

Bring the graph from any quiescent state to running, in dependency order — cold boot AND re-entry (a sub-graph supervisor is legitimately start()/teardown()-cycled per app phase). Idempotent: running nodes are skipped; detached nodes are skipped on re-entry (their instance survived the teardown — the first start still spawns them, the flag is app-set afterwards); a Pause instance parked by an earlier teardown is resumed in place (never double-spawned; like resume_pausable this bypasses the gate waits, since the parked instance retains its resources and its slots are empty by design). Mode::OnDemand nodes are skipped — they’re brought up at

Source

pub async fn run(&self, spawner: &Spawner) -> NodeFault

Run this node to completion, handling start, driver, and monitoring.

Source

pub async fn monitor(&self) -> Infallible

Monitor node liveness beats and restart nodes that miss deadlines.

Source

pub async fn start_node( &self, node: &'static TaskNode, spawner: &Spawner, ) -> Result<(), NodeFault>

Start a single node if it is not already running and not detached.

Source

pub async fn stop_node(&self, node: &'static TaskNode) -> Result<(), NodeFault>

Stop a single node, waiting for its shutdown ack.

Source

pub async fn teardown(&self) -> Result<(), NodeFault>

Stop every running node, dependents before their dependencies. Down OnDemand nodes are skipped (no instance to ack). Pause-mode nodes ack and park on wait_resume(); Terminate/OnDemand nodes exit.

The stop runs as a wave: a node is signalled once every dependent stopping with it has acked — a deps: dependency keeps serving through its dependents’ cleanup — and a node with no such dependents

Source

pub async fn teardown_continue(&self) -> Result<(), NodeFault>

Like teardown, but do not clear the shutdown flags so a later respawn_terminate can restart.

Source

pub fn resume_node(&self, node: &'static TaskNode)

Resume a single parked Pause-mode node.

Source

pub fn resume_pausable(&self)

Signal every parked Pause-mode node to resume. Cheap and synchronous — the tasks were parked on wait_resume() and pick up immediately. Called separately from respawn_terminate so the application can fire resume independently of the respawn step. Disabled (manually-paused) nodes are skipped so a manual pause sticks, detached (self-managed) Pause nodes are left parked, and — as in resume_node — a node without a parked instance (has_acked_stop) is skipped: signaling it would latch resume_wake with no waiter, and the node’s next park

Source

pub async fn respawn_terminate( &self, spawner: &Spawner, ) -> Result<(), NodeFault>

Restart every terminated Terminate-mode node that is not running, disabled, or detached.

Source§

impl<const N: usize, T: Topology<N>> Supervisor<N, T>

Source

pub async fn apply_control( &self, cmd: ControlCommand, spawner: &Spawner, ) -> Result<(), NodeFault>

Apply a control command to the requested node.

Source

pub async fn deactivate( &self, target: &'static TaskNode, ) -> Result<(), NodeFault>

Deactivate the target node and all of its dependents.

Source

pub async fn activate(&self, target: &'static TaskNode, spawner: &Spawner)

Bring target (and its pool, and every transitive dependency) up, in topological order so each dependency starts before its dependent — the cascading “turn this subsystem on” verb, and the entry half of the subordinate sub-graph pattern’s one-graph variant: activate on a

Source§

impl<const N: usize, T: Topology<N>> Supervisor<N, T>

Source

pub async fn apply_bind(&self, spawner: &Spawner) -> Result<(), NodeFault>

React to bound-dependency readiness changes by stopping or resuming nodes.

Source§

impl<const N: usize, T: Topology<N>> Supervisor<N, T>

Source

pub async fn restart( &self, target: &'static TaskNode, spawner: &Spawner, ) -> Result<(), NodeFault>

Restart the target node and all of its dependents.

Auto Trait Implementations§

§

impl<const N: usize, T = Ordered<N, { shape::ALL }>> !RefUnwindSafe for Supervisor<N, T>

§

impl<const N: usize, T = Ordered<N, { shape::ALL }>> !UnwindSafe for Supervisor<N, T>

§

impl<const N: usize, T> Freeze for Supervisor<N, T>
where &'static [Option<&'static TaskNode>; N]: Freeze, &'static T: Freeze,

§

impl<const N: usize, T> Send for Supervisor<N, T>
where &'static [Option<&'static TaskNode>; N]: Send, &'static T: Send,

§

impl<const N: usize, T> Sync for Supervisor<N, T>
where &'static [Option<&'static TaskNode>; N]: Sync, &'static T: Sync,

§

impl<const N: usize, T> Unpin for Supervisor<N, T>
where &'static [Option<&'static TaskNode>; N]: Unpin, &'static T: Unpin,

§

impl<const N: usize, T> UnsafeUnpin for Supervisor<N, T>
where &'static [Option<&'static TaskNode>; N]: UnsafeUnpin, &'static T: UnsafeUnpin,

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<T> CouplingPoint for T
where T: Sync + ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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