Skip to main content

SupervisorConfig

Struct SupervisorConfig 

Source
pub struct SupervisorConfig {
    pub grace: Duration,
    pub max_concurrent: usize,
    pub bus_capacity: usize,
    pub restart: RestartPolicy,
    pub backoff: BackoffPolicy,
    pub timeout: Duration,
}
Expand description

Global configuration for the supervisor runtime.

Defines:

  • Shutdown behavior: grace period for graceful termination
  • Concurrency limits: max simultaneous tasks
  • Event system: bus capacity for event delivery
  • Task defaults: restart policy, backoff strategy, timeout

§Field semantics

  • grace: Maximum wait for tasks to stop gracefully (0s = no wait, force immediately)
  • max_concurrent: Task concurrency limit (0 = unlimited)
  • bus_capacity: Event bus ring buffer size (min 1; clamped by Bus)
  • timeout: Default per-task timeout (0s = no timeout)
  • restart: Default restart policy (can be overridden per-task)
  • backoff: Default backoff strategy (can be overridden per-task)

§Notes

All fields are public for flexibility. Prefer using helper accessors to avoid sprinkling sentinel checks (0) across the codebase.

Fields§

§grace: Duration

Maximum time to wait for graceful shutdown before force-terminating.

When a shutdown signal is received:

  • Tasks are cancelled via CancellationToken
  • Supervisor waits up to grace for tasks to exit
  • If timeout exceeds, returns RuntimeError::GraceExceeded
§max_concurrent: usize

Maximum number of tasks to run concurrently.

  • 0 = unlimited (no semaphore)
  • n > 0 = at most n tasks run simultaneously

Applied globally across all tasks in the supervisor.

§bus_capacity: usize

Capacity of the event bus broadcast channel ring buffer.

Slow subscribers that lag behind more than bus_capacity messages will receive Lagged and skip older items. Minimum value is 1 (enforced by Bus).

§restart: RestartPolicy

Default restart policy for tasks.

Used by TaskSpec::with_defaults(). Can be overridden per-task.

§backoff: BackoffPolicy

Default backoff policy for retries.

Used by TaskSpec::with_defaults(). Can be overridden per-task.

§timeout: Duration

Default task timeout.

  • Duration::ZERO = no timeout (task runs until completion)
  • > 0 = timeout applied per task attempt

Used by TaskSpec::with_defaults(). Can be overridden per-task.

Implementations§

Source§

impl SupervisorConfig

Source

pub fn concurrency_limit(&self) -> Option<usize>

Returns the global concurrency limit as an Option.

  • None → unlimited (no semaphore)
  • Some(n) → at most n concurrent tasks
Source

pub fn default_timeout(&self) -> Option<Duration>

Returns the default per-task timeout as an Option.

  • None → no timeout
  • Some(d) → timeout applied per attempt
Source

pub fn bus_capacity_clamped(&self) -> usize

Returns a bus capacity clamped to a minimum of 1.

The Bus should use this value to avoid constructing an invalid channel.

Trait Implementations§

Source§

impl Clone for SupervisorConfig

Source§

fn clone(&self) -> SupervisorConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SupervisorConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SupervisorConfig

Source§

fn default() -> Self

Default configuration:

  • grace = 60s (reasonable graceful shutdown window)
  • max_concurrent = 0 (unlimited)
  • bus_capacity = 1024 (good baseline)
  • timeout = 0s (no timeout)
  • restart = RestartPolicy::OnFailure (restart on errors only)
  • backoff = BackoffPolicy::default() (exponential backoff)

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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