pub struct ControllerConfig { /* private fields */ }controller only.Expand description
Resource limits for one supervisor’s controller.
Pass this value to SupervisorBuilder::with_controller
before building the supervisor. Default configures every limit to a finite value and can be used without further changes.
§What each limit controls
identity_operation_capacitybounds concurrent registry-backed remove and cancel operations.max_total_pendingbounds slot-queue entries plus waits for runtime registry command capacity.admission_capacitybounds waits for runtime registry command capacity.max_controller_slotsbounds distinct slots tracked at once.queue_capacitybounds commands waiting for the controller loop.max_slot_queuebounds FIFO work behind one busy slot owner.
§How limits appear to callers
Async submit methods wait when the ordered command queue is full. Their fail-fast try_* forms
return ControllerError::Full. Admission limits are checked later.
A watched submit reports them through TaskOutcome::Rejected. A full slot queue
uses RejectionKind::QueueFull. The admission, slot-count, and total-pending
budgets use RejectionKind::ResourceLimit.
A remove or cancel call that must reach the registry returns RuntimeError::ResourceLimitReached
when this operation budget is exhausted. Controller-local queued removal is handled before this limit.
§Examples
use std::num::NonZeroUsize;
use taskvisor::ControllerConfig;
let config = ControllerConfig::default()
.with_queue_capacity(NonZeroUsize::new(256).unwrap())
.with_max_slot_queue(32)
.with_max_controller_slots(NonZeroUsize::new(512));
assert_eq!(config.queue_capacity().get(), 256);
assert_eq!(config.max_slot_queue(), 32);Implementations§
Source§impl ControllerConfig
impl ControllerConfig
Sourcepub const fn new(queue_capacity: NonZeroUsize, max_slot_queue: usize) -> Self
pub const fn new(queue_capacity: NonZeroUsize, max_slot_queue: usize) -> Self
Creates a configuration from command capacity and per-slot queue depth.
The admission budget, identity-operation budget, slot limit, and total pending limit all start at queue_capacity.
Configuration methods can tune them independently.
SupervisorBuilder::try_build rejects a command capacity above the async implementation limit.
A max_slot_queue value of 0 rejects every Queue submission behind a busy slot.
Replace can still create or replace the queue head.
Sourcepub fn try_new(
queue_capacity: usize,
max_slot_queue: usize,
) -> Result<Self, ConfigError>
pub fn try_new( queue_capacity: usize, max_slot_queue: usize, ) -> Result<Self, ConfigError>
Creates a configuration from a raw command-queue capacity.
§Errors
Returns ConfigError::Zero when queue_capacity is zero, or
ConfigError::TooLarge above the bounded async implementation limit.
Sourcepub const fn queue_capacity(&self) -> NonZeroUsize
pub const fn queue_capacity(&self) -> NonZeroUsize
Returns the ordered controller command-channel capacity.
Sourcepub const fn admission_capacity(&self) -> NonZeroUsize
pub const fn admission_capacity(&self) -> NonZeroUsize
Returns the number of registry-capacity reservations allowed at once.
Sourcepub const fn identity_operation_capacity(&self) -> NonZeroUsize
pub const fn identity_operation_capacity(&self) -> NonZeroUsize
Returns the concurrent registry-backed remove and cancel budget.
Sourcepub const fn max_slot_queue(&self) -> usize
pub const fn max_slot_queue(&self) -> usize
Returns the per-slot pending limit checked by Queue submissions.
The owner is excluded. A replacement head is included.
Replace does not use this limit.
Sourcepub const fn max_controller_slots(&self) -> Option<NonZeroUsize>
pub const fn max_controller_slots(&self) -> Option<NonZeroUsize>
Returns the tracked-slot limit, or None if it is disabled.
The default equals the command capacity passed to new.
Sourcepub const fn max_total_pending(&self) -> Option<NonZeroUsize>
pub const fn max_total_pending(&self) -> Option<NonZeroUsize>
Returns the total pending-submission limit, or None if disabled.
Slot queues and waits for registry command capacity are included.
Buffered controller commands and tasks already handed to the registry are excluded.
The default equals the command capacity passed to new.
Sourcepub const fn with_queue_capacity(self, queue_capacity: NonZeroUsize) -> Self
pub const fn with_queue_capacity(self, queue_capacity: NonZeroUsize) -> Self
Sets the command-channel capacity without changing the other limits.
SupervisorBuilder::try_build
rejects values above the bounded async implementation limit.
Sourcepub fn try_with_queue_capacity(
self,
queue_capacity: usize,
) -> Result<Self, ConfigError>
pub fn try_with_queue_capacity( self, queue_capacity: usize, ) -> Result<Self, ConfigError>
Sets and validates a raw command-queue capacity.
§Errors
Returns ConfigError::Zero when queue_capacity is zero, or
ConfigError::TooLarge above the bounded async implementation limit.
Sourcepub const fn with_admission_capacity(
self,
admission_capacity: NonZeroUsize,
) -> Self
pub const fn with_admission_capacity( self, admission_capacity: NonZeroUsize, ) -> Self
Sets the number of registry-capacity reservations allowed at once.
Sourcepub fn try_with_admission_capacity(
self,
admission_capacity: usize,
) -> Result<Self, ConfigError>
pub fn try_with_admission_capacity( self, admission_capacity: usize, ) -> Result<Self, ConfigError>
Sets the registry-capacity wait budget from a raw integer.
§Errors
Returns ConfigError::Zero when admission_capacity is zero.
Sourcepub const fn with_identity_operation_capacity(
self,
identity_operation_capacity: NonZeroUsize,
) -> Self
pub const fn with_identity_operation_capacity( self, identity_operation_capacity: NonZeroUsize, ) -> Self
Sets the concurrent registry-backed remove and cancel budget.
Sourcepub fn try_with_identity_operation_capacity(
self,
identity_operation_capacity: usize,
) -> Result<Self, ConfigError>
pub fn try_with_identity_operation_capacity( self, identity_operation_capacity: usize, ) -> Result<Self, ConfigError>
Sets the identity-operation budget from a raw integer.
§Errors
Returns ConfigError::Zero when identity_operation_capacity is zero.
Sourcepub const fn with_max_slot_queue(self, max_slot_queue: usize) -> Self
pub const fn with_max_slot_queue(self, max_slot_queue: usize) -> Self
Sets the per-slot pending limit checked by Queue submissions.
0 rejects Queue submissions behind a busy slot.
Replace may still create or replace the queue head.
Sourcepub const fn with_max_controller_slots(
self,
max_controller_slots: Option<NonZeroUsize>,
) -> Self
pub const fn with_max_controller_slots( self, max_controller_slots: Option<NonZeroUsize>, ) -> Self
Sets the tracked-slot limit, or disables it with None.
Sourcepub fn try_with_max_controller_slots(
self,
max_controller_slots: usize,
) -> Result<Self, ConfigError>
pub fn try_with_max_controller_slots( self, max_controller_slots: usize, ) -> Result<Self, ConfigError>
Sets the aggregate controller-slot limit from a raw integer.
§Errors
Returns ConfigError::Zero when max_controller_slots is zero.
Sourcepub const fn with_max_total_pending(
self,
max_total_pending: Option<NonZeroUsize>,
) -> Self
pub const fn with_max_total_pending( self, max_total_pending: Option<NonZeroUsize>, ) -> Self
Sets the total pending-submission limit, or disables it with None.
Sourcepub fn try_with_max_total_pending(
self,
max_total_pending: usize,
) -> Result<Self, ConfigError>
pub fn try_with_max_total_pending( self, max_total_pending: usize, ) -> Result<Self, ConfigError>
Sets the aggregate pending-submission limit from a raw integer.
§Errors
Returns ConfigError::Zero when max_total_pending is zero.
Trait Implementations§
Source§impl Clone for ControllerConfig
impl Clone for ControllerConfig
Source§fn clone(&self) -> ControllerConfig
fn clone(&self) -> ControllerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more