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
impl SupervisorConfig
Sourcepub const fn grace(&self) -> Duration
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.
Sourcepub const fn subscriber_shutdown_timeout(&self) -> Duration
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.
Sourcepub const fn max_concurrent(&self) -> Option<NonZeroUsize>
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.
Sourcepub const fn max_registered_tasks(&self) -> Option<NonZeroUsize>
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.
Sourcepub const fn ownership_capacity(&self) -> Option<NonZeroUsize>
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.
Sourcepub const fn bus_capacity(&self) -> NonZeroUsize
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.
Sourcepub const fn registry_queue_capacity(&self) -> NonZeroUsize
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.
Sourcepub const fn with_grace(self, grace: Duration) -> Self
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.
Sourcepub const fn with_subscriber_shutdown_timeout(self, timeout: Duration) -> Self
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.
Sourcepub const fn with_max_concurrent(
self,
max_concurrent: Option<NonZeroUsize>,
) -> Self
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.
Sourcepub fn try_with_max_concurrent(
self,
max_concurrent: usize,
) -> Result<Self, ConfigError>
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
ConfigError::Zerowhenmax_concurrentis zero;ConfigError::TooLargewhenmax_concurrentexceeds Tokio’s structural limit.
Sourcepub const fn with_max_registered_tasks(
self,
max_registered_tasks: Option<NonZeroUsize>,
) -> Self
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.
Sourcepub fn try_with_max_registered_tasks(
self,
max_registered_tasks: usize,
) -> Result<Self, ConfigError>
pub fn try_with_max_registered_tasks( self, max_registered_tasks: usize, ) -> Result<Self, ConfigError>
Registry membership limit from a raw integer.
§Errors
ConfigError::Zerowhenmax_registered_tasksis zero.
Sourcepub const fn with_ownership_capacity(
self,
ownership_capacity: Option<NonZeroUsize>,
) -> Self
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.
Sourcepub fn try_with_ownership_capacity(
self,
ownership_capacity: usize,
) -> Result<Self, ConfigError>
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
ConfigError::Zerowhenownership_capacityis zero.
Sourcepub const fn with_bus_capacity(self, bus_capacity: NonZeroUsize) -> Self
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.
Sourcepub fn try_with_bus_capacity(
self,
bus_capacity: usize,
) -> Result<Self, ConfigError>
pub fn try_with_bus_capacity( self, bus_capacity: usize, ) -> Result<Self, ConfigError>
Event-bus capacity from a raw integer.
§Errors
ConfigError::Zerowhenbus_capacityis zero;ConfigError::TooLargewhenbus_capacityexceeds Tokio’s structural limit.
Sourcepub const fn with_registry_queue_capacity(
self,
registry_queue_capacity: NonZeroUsize,
) -> Self
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.
Sourcepub fn try_with_registry_queue_capacity(
self,
registry_queue_capacity: usize,
) -> Result<Self, ConfigError>
pub fn try_with_registry_queue_capacity( self, registry_queue_capacity: usize, ) -> Result<Self, ConfigError>
Registry management-queue capacity from a raw integer.
§Errors
ConfigError::Zerowhenregistry_queue_capacityis zero;ConfigError::TooLargewhenregistry_queue_capacityexceeds Tokio’s structural limit.
Trait Implementations§
Source§impl Clone for SupervisorConfig
impl Clone for SupervisorConfig
Source§fn clone(&self) -> SupervisorConfig
fn clone(&self) -> SupervisorConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more