Skip to main content

SupervisorConfig

Struct SupervisorConfig 

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

Immutable runtime-wide settings for one supervisor.

These settings control task shutdown, subscriber draining, bounded queues, registry membership, event ingress, concurrent attempts, and user lifetimes retained for cleanup. Start with Default and change the limits needed by the application. Pass the result to Supervisor::new or Supervisor::builder.

Implementations§

Source§

impl SupervisorConfig

Source

pub const fn new() -> Self

Built-in runtime configuration available in const contexts.

Source

pub const fn grace(&self) -> Duration

Cooperative task-stop window before logical force-abort.

Explicit removal, requested shutdown, and natural shutdown use this window. After it expires, Taskvisor commits a logical force-abort. The physical task code may remain active after that point. Zero skips the wait.

Source

pub const fn subscriber_shutdown_timeout(&self) -> Duration

Shared deadline for draining subscriber queues.

Zero closes the queues without waiting for pending events. The deadline can drop queued events. It cannot stop a callback already running.

Source

pub const fn max_concurrent(&self) -> Option<NonZeroUsize>

Limit for task attempts running at the same time.

None means no limit. Permit waits and retry backoff do not count. A started attempt holds its permit until its physical attempt boundary exits.

Source

pub const fn max_registered_tasks(&self) -> Option<NonZeroUsize>

Registry membership limit.

Registered and removing tasks count until terminal cleanup removes their identity. Force-aborted work can keep consuming the limit after membership ends. During cleanup handoff, one task may temporarily consume two units.

None disables this limit. The separately configured ownership_capacity still applies.

Source

pub const fn ownership_capacity(&self) -> Option<NonZeroUsize>

Limit for user lifetimes owned by this supervisor.

Configured subscribers and accepted tasks share this limit. Each accepted lifetime keeps one unit through queued work, physical execution, and isolated terminal destruction. Force-aborted work can remain charged after logical completion. A destructor panic permanently retires its unit from a finite limit. A finite limit below the internal cleanup-worker ceiling also lowers that ceiling.

None removes the ownership admission limit. Destructor isolation and its worker ceiling remain active. Blocked destructors can then retain an unbounded number of user values and cleanup batches.

Source

pub const fn bus_capacity(&self) -> NonZeroUsize

Number of newest events retained by the event ingress.

The bus remains best-effort. When publishers outrun the relay, older events are replaced and loss is reported through overflow diagnostics.

Source

pub const fn registry_queue_capacity(&self) -> NonZeroUsize

Capacity of the registry management queue.

Default direct-registry operations wait for this capacity. Operations configured with fail_fast() return RuntimeError::CommandQueueFull when no slot is available immediately.

Source

pub const fn with_grace(self, grace: Duration) -> Self

Cooperative task-stop window before logical force-abort.

Values above 30 years are normalized to 30 years. grace always returns the effective value used by timeout logic and diagnostics.

Source

pub const fn with_subscriber_shutdown_timeout(self, timeout: Duration) -> Self

Shared deadline for draining subscriber queues.

Zero closes the queues without waiting for pending events. The deadline does not interrupt a subscriber callback already running.

Source

pub const fn with_max_concurrent( self, max_concurrent: Option<NonZeroUsize>, ) -> Self

Optional limit for task attempts running at the same time.

SupervisorBuilder::try_build rejects values above Tokio’s structural limit. Use try_with_max_concurrent for a raw integer. Pass None to remove the limit.

Source

pub fn try_with_max_concurrent( self, max_concurrent: usize, ) -> Result<Self, ConfigError>

Task-attempt concurrency limit from a raw integer.

Use with_max_concurrent with None for no limit.

§Errors
Source

pub const fn with_max_registered_tasks( self, max_registered_tasks: Option<NonZeroUsize>, ) -> Self

Optional registry membership limit.

Registered and removing tasks count until terminal cleanup finishes. Force-aborted work can keep consuming the limit after membership ends. None disables only this limit. It does not change the separate ownership_capacity setting.

Use try_with_max_registered_tasks for a raw integer.

Source

pub fn try_with_max_registered_tasks( self, max_registered_tasks: usize, ) -> Result<Self, ConfigError>

Registry membership limit from a raw integer.

§Errors
Source

pub const fn with_ownership_capacity( self, ownership_capacity: Option<NonZeroUsize>, ) -> Self

Optional limit for user lifetimes owned by this supervisor.

Configured subscribers and accepted tasks share the limit. None disables ownership admission backpressure but keeps destructor isolation and its worker ceiling enabled. Without this limit, blocked destructors can retain an unbounded number of user values and cleanup batches. A finite limit below the internal cleanup-worker ceiling also lowers that ceiling.

Use try_with_ownership_capacity for a raw integer.

Source

pub fn try_with_ownership_capacity( self, ownership_capacity: usize, ) -> Result<Self, ConfigError>

User-lifetime ownership limit from a raw integer.

Use with_ownership_capacity with None for no limit.

§Errors
Source

pub const fn with_bus_capacity(self, bus_capacity: NonZeroUsize) -> Self

Number of newest events retained by the event ingress.

Increasing this value absorbs a larger event burst but does not make lifecycle events reliable.

SupervisorBuilder::try_build rejects values above Tokio’s structural limit.

Source

pub fn try_with_bus_capacity( self, bus_capacity: usize, ) -> Result<Self, ConfigError>

Event-bus capacity from a raw integer.

§Errors
Source

pub const fn with_registry_queue_capacity( self, registry_queue_capacity: NonZeroUsize, ) -> Self

Capacity of the registry management queue.

This bounds management commands waiting for the registry. It does not change the task membership or attempt-concurrency limits.

SupervisorBuilder::try_build rejects values above Tokio’s structural limit.

Source

pub fn try_with_registry_queue_capacity( self, registry_queue_capacity: usize, ) -> Result<Self, ConfigError>

Registry management-queue capacity from a raw integer.

§Errors

Trait Implementations§

Source§

impl Clone for SupervisorConfig

Source§

fn clone(&self) -> SupervisorConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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

Built-in runtime configuration.

Defaults:

  • graceful task shutdown: 60 seconds,
  • subscriber drain: 5 seconds,
  • task-attempt concurrency: unlimited,
  • registered-task membership: 1024,
  • owned user lifetimes: 1024,
  • event bus capacity: 1024,
  • registry command capacity: 1024.

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> 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> 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 = !

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