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 gives every limit a finite value.

§What each limit controls

§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

Source

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.

Source

pub fn try_new( queue_capacity: usize, max_slot_queue: usize, ) -> Result<Self, ConfigError>

Validated controller limits from a raw command-queue capacity.

§Errors
Source

pub const fn queue_capacity(&self) -> NonZeroUsize

Ordered controller command-channel capacity.

Source

pub const fn admission_capacity(&self) -> NonZeroUsize

Maximum simultaneous registry-capacity reservations.

Source

pub const fn identity_operation_capacity(&self) -> NonZeroUsize

Concurrent registry-backed remove and cancel budget.

Source

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.

Source

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

Optional tracked-slot limit.

The default equals the command capacity passed to new.

Source

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.

Source

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.

Source

pub fn try_with_queue_capacity( self, queue_capacity: usize, ) -> Result<Self, ConfigError>

Validated command-queue capacity from a raw integer.

§Errors
Source

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

Registry-capacity reservation budget.

Source

pub fn try_with_admission_capacity( self, admission_capacity: usize, ) -> Result<Self, ConfigError>

Registry-capacity reservation budget from a raw integer.

§Errors
Source

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

Concurrent registry-backed remove and cancel budget.

Source

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
Source

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.

Source

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

Optional tracked-slot limit.

Source

pub fn try_with_max_controller_slots( self, max_controller_slots: usize, ) -> Result<Self, ConfigError>

Tracked-slot limit from a raw integer.

§Errors
Source

pub const fn with_max_total_pending( self, max_total_pending: Option<NonZeroUsize>, ) -> Self

Optional total pending-submission limit.

Source

pub fn try_with_max_total_pending( self, max_total_pending: usize, ) -> Result<Self, ConfigError>

Total pending-submission limit from a raw integer.

§Errors

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

Default bounded controller limits.

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

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