Skip to main content

ControllerConfig

Struct ControllerConfig 

Source
pub struct ControllerConfig { /* private fields */ }
Available on crate feature 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

§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

Source

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.

Source

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.

Source

pub const fn queue_capacity(&self) -> NonZeroUsize

Returns the ordered controller command-channel capacity.

Source

pub const fn admission_capacity(&self) -> NonZeroUsize

Returns the number of registry-capacity reservations allowed at once.

Source

pub const fn identity_operation_capacity(&self) -> NonZeroUsize

Returns the concurrent registry-backed remove and cancel budget.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub const fn with_admission_capacity( self, admission_capacity: NonZeroUsize, ) -> Self

Sets the number of registry-capacity reservations allowed at once.

Source

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.

Source

pub const fn with_identity_operation_capacity( self, identity_operation_capacity: NonZeroUsize, ) -> Self

Sets the concurrent registry-backed remove and cancel budget.

Source

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.

Source

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.

Source

pub const fn with_max_controller_slots( self, max_controller_slots: Option<NonZeroUsize>, ) -> Self

Sets the tracked-slot limit, or disables it with None.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> ControllerConfig

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 ControllerConfig

Source§

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

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

impl Default for ControllerConfig

Source§

fn default() -> Self

Returns the default controller configuration.

Defaults:

  • queue_capacity = 1024
  • admission_capacity = 1024
  • identity_operation_capacity = 1024
  • max_slot_queue = 100
  • max_controller_slots = 1024
  • max_total_pending = 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 = 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<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