Skip to main content

TaskSpec

Struct TaskSpec 

Source
pub struct TaskSpec<P> {
Show 15 fields pub payload: Arc<P>, pub kind: Arc<str>, pub pool: Arc<str>, pub priority: Priority, pub key: Option<Arc<str>>, pub deadline: Option<Time>, pub fixed_start: Option<FixedStart>, pub duration_hint: Option<Duration>, pub timeout: Option<Duration>, pub retry: Option<RetryPolicy>, pub deps: Vec<Dep>, pub resources: SmallVec<[(Arc<str>, u32); 2]>, pub tags: Vec<(Arc<str>, Arc<str>)>, pub labels: Vec<(Arc<str>, Arc<str>)>, pub tenant: Option<Arc<str>>,
}
Expand description

Everything the engine needs to schedule one task.

Built with TaskSpec::new and the chained setters; all fields are public for direct use.

Fields§

§payload: Arc<P>

The work itself, handed to the executor unchanged.

§kind: Arc<str>

Free-form category; duration statistics are learned per (pool, kind).

§pool: Arc<str>

Pool that runs the task (default "default").

§priority: Priority

Priority class.

§key: Option<Arc<str>>

Optional unique key: deduplicates submissions while the task is live or retained, and lets dependents refer to it by name.

§deadline: Option<Time>

Soft deadline for completion; urgency rises as its latest start time approaches.

§fixed_start: Option<FixedStart>

Start at (or close to) a given time, with capacity reserved in advance.

§duration_hint: Option<Duration>

Expected runtime; when absent the engine uses learned statistics.

§timeout: Option<Duration>

Per-attempt timeout.

§retry: Option<RetryPolicy>

None uses the pool default.

§deps: Vec<Dep>

Tasks that must finish first (see Dep).

§resources: SmallVec<[(Arc<str>, u32); 2]>

Shared resources needed while running: (resource name, amount).

§tags: Vec<(Arc<str>, Arc<str>)>

Labels passed through to executors (e.g. traceparent, tenant).

§labels: Vec<(Arc<str>, Arc<str>)>

Worker labels this task requires: it runs only on a worker group whose labels include every (name, value) pair (see Core::set_group_capacity).

§tenant: Option<Arc<str>>

Tenant the task belongs to, for weighted fair sharing of pools with PoolConfig::fairness.

Implementations§

Source§

impl<P> TaskSpec<P>

Source

pub fn map_payload<Q>(self, payload: Arc<Q>) -> TaskSpec<Q>

Same task description with a different payload type.

Source

pub fn new(payload: P) -> Self

A Normal task in the "default" pool.

Source

pub fn from_arc(payload: Arc<P>) -> Self

Like TaskSpec::new with an already shared payload.

Source

pub fn kind(self, k: impl Into<Arc<str>>) -> Self

Set the kind.

Source

pub fn pool(self, p: impl Into<Arc<str>>) -> Self

Set the pool.

Source

pub fn priority(self, p: Priority) -> Self

Set the priority class.

Source

pub fn key(self, k: impl Into<Arc<str>>) -> Self

Set the unique key.

Source

pub fn deadline(self, t: Time) -> Self

Set the deadline.

Source

pub fn fixed_start(self, f: FixedStart) -> Self

Set a fixed start.

Source

pub fn duration_hint(self, d: Duration) -> Self

Set the expected runtime.

Source

pub fn timeout(self, d: Duration) -> Self

Set the per-attempt timeout.

Source

pub fn retry(self, r: RetryPolicy) -> Self

Set the retry policy.

Source

pub fn dep(self, d: Dep) -> Self

Add a dependency.

Source

pub fn after(self, target: impl Into<TaskRef>) -> Self

Run after target succeeds.

Source

pub fn resource(self, name: impl Into<Arc<str>>, amount: u32) -> Self

Require amount units of a resource while running.

Source

pub fn tag(self, k: impl Into<Arc<str>>, v: impl Into<Arc<str>>) -> Self

Add a label.

Source

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

The tenant the task belongs to (for fair sharing).

Source

pub fn label( self, name: impl Into<Arc<str>>, value: impl Into<Arc<str>>, ) -> Self

Require a worker label (name = value) to run.

Trait Implementations§

Source§

impl<P> Clone for TaskSpec<P>

Source§

fn clone(&self) -> Self

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<P: Debug> Debug for TaskSpec<P>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<P> Freeze for TaskSpec<P>
where Arc<P>: Freeze,

§

impl<P> RefUnwindSafe for TaskSpec<P>
where Arc<P>: RefUnwindSafe,

§

impl<P> Send for TaskSpec<P>
where Arc<P>: Send,

§

impl<P> Sync for TaskSpec<P>
where Arc<P>: Sync,

§

impl<P> Unpin for TaskSpec<P>
where Arc<P>: Unpin,

§

impl<P> UnsafeUnpin for TaskSpec<P>
where Arc<P>: UnsafeUnpin,

§

impl<P> UnwindSafe for TaskSpec<P>
where Arc<P>: UnwindSafe,

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

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.