Skip to main content

ControllerSpec

Struct ControllerSpec 

Source
pub struct ControllerSpec { /* private fields */ }
Available on crate feature controller only.
Expand description

Describes one task submission through the controller.

A ControllerSpec does not run a task by itself. It stores the task, the busy-slot policy, and the target slot.

The slot is admission metadata. It is not part of the task execution model. The task still runs according to its TaskSpec.

§Example

use taskvisor::{ControllerSpec, TaskFn, TaskRef, TaskSpec};

let task: TaskRef = TaskFn::arc("deploy-main-42", |_ctx| async {
    Ok(())
});

let spec = ControllerSpec::queue(TaskSpec::once(task)).with_slot("deploy-main");

assert_eq!(spec.slot_name(), "deploy-main");

§See also

Implementations§

Source§

impl ControllerSpec

Source

pub fn new(admission: AdmissionPolicy, task_spec: TaskSpec) -> Self

Creates a submission spec from an admission policy and a task spec.

The slot defaults to the task name. Use with_slot to group several task names under one slot.

Source

pub fn admission(&self) -> AdmissionPolicy

Returns the admission policy used when the target slot is busy.

Source

pub fn with_admission(self, admission: AdmissionPolicy) -> Self

Sets the admission policy used when the target slot is busy.

Source

pub fn task_spec(&self) -> &TaskSpec

Returns the task execution specification.

Source

pub fn with_task_spec(self, task_spec: TaskSpec) -> Self

Replaces the task execution specification.

When no explicit slot is configured, the effective slot changes to the name of the replacement task. An explicit slot is preserved.

Source

pub fn into_task_spec(self) -> TaskSpec

Consumes this submission spec and returns its task execution specification.

Controller-only metadata such as the admission policy and slot override is discarded.

Source

pub fn with_slot(self, slot: impl Into<Arc<str>>) -> Self

Sets the admission slot key.

The slot is the controller’s admission unit: only one registered task can own a slot at a time.

Use the same slot for work that must not run in parallel. Use different slots for work that may run independently.

Source

pub fn without_slot(self) -> Self

Removes an explicit slot override.

After this call, slot_name falls back to the current task name.

Source

pub fn slot_name(&self) -> &str

Returns the effective slot key.

If with_slot was not used, this returns the task name from TaskSpec::name.

Source

pub fn slot_override(&self) -> Option<&str>

Returns the explicit slot override, if one was configured.

Unlike slot_name, this does not fall back to the task name.

Source

pub fn queue(task_spec: TaskSpec) -> Self

Creates a submission with FIFO queue admission.

If the slot is idle, the controller tries to start registry admission. If the slot is busy, the submission is appended behind older pending work when ControllerConfig::max_slot_queue allows it; otherwise it is rejected.

Source

pub fn replace(task_spec: TaskSpec) -> Self

Creates a replacement submission.

If the slot is idle, the controller tries to start registry admission. If the slot is busy, this submission becomes the queue head. The controller retires a registered owner, or waits for a pending registration decision before deciding whether removal is needed.

An existing head is rejected and replaced, even when it came from Queue. Existing FIFO items behind the head remain queued. Repeated replacements therefore keep only the latest head without growing the queue.

Source

pub fn drop_if_running(task_spec: TaskSpec) -> Self

Creates a submit-if-idle submission.

If the slot is idle, the controller tries to start registry admission. If the slot is busy, the submission is rejected instead of queued.

Trait Implementations§

Source§

impl Clone for ControllerSpec

Source§

fn clone(&self) -> ControllerSpec

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 ControllerSpec

Source§

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

Formats the value using the given formatter. Read more

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