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 gives every limit a finite value.
§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
Submit::execute waits when the ordered command queue is full.
Submit::try_intake instead returns
ControllerError::Full. Admission limits are checked later.
A submission configured with watch() 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 operation that must reach the registry returns RuntimeError::ResourceLimitReached
from execute().await when the identity-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
Controller limits initialized from command capacity and per-slot queue depth.
The admission and identity-operation budgets start at queue_capacity.
The optional slot and total-pending limits also 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>
Validated controller limits from a raw command-queue capacity.
§Errors
ConfigError::Zerowhenqueue_capacityis zero;ConfigError::TooLargewhenqueue_capacityexceeds the bounded async implementation limit.
Sourcepub const fn queue_capacity(&self) -> NonZeroUsize
pub const fn queue_capacity(&self) -> NonZeroUsize
Ordered controller command-channel capacity.
Sourcepub const fn admission_capacity(&self) -> NonZeroUsize
pub const fn admission_capacity(&self) -> NonZeroUsize
Maximum simultaneous registry-capacity reservations.
Sourcepub const fn identity_operation_capacity(&self) -> NonZeroUsize
pub const fn identity_operation_capacity(&self) -> NonZeroUsize
Concurrent registry-backed remove and cancel budget.
Sourcepub const fn max_slot_queue(&self) -> usize
pub const fn max_slot_queue(&self) -> usize
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>
Optional tracked-slot limit.
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>
Optional total pending-submission limit.
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
Command-channel capacity with all other limits unchanged.
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>
Validated command-queue capacity from a raw integer.
§Errors
ConfigError::Zerowhenqueue_capacityis zero;ConfigError::TooLargewhenqueue_capacityexceeds 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
Registry-capacity reservation budget.
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>
Registry-capacity reservation budget from a raw integer.
§Errors
ConfigError::Zerowhenadmission_capacityis 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
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>
Registry-backed identity-operation budget from a raw integer.
§Errors
ConfigError::Zerowhenidentity_operation_capacityis 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
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
Optional tracked-slot limit.
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>
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
Optional total pending-submission limit.
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>
Total pending-submission limit from a raw integer.
§Errors
ConfigError::Zerowhenmax_total_pendingis 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