pub struct Task<P> { /* private fields */ }Expand description
A task to submit. Wraps TaskSpec and resolves times at submission.
Implementations§
Source§impl<P> Task<P>
impl<P> Task<P>
Sourcepub fn new(payload: P) -> Self
pub fn new(payload: P) -> Self
A task with default settings: pool and kind "default", priority Normal.
Sourcepub fn spec(&self) -> &TaskSpec<P>
pub fn spec(&self) -> &TaskSpec<P>
The underlying engine spec (times given relatively are resolved at submission).
Sourcepub fn kind(self, k: impl Into<Arc<str>>) -> Self
pub fn kind(self, k: impl Into<Arc<str>>) -> Self
Task kind: groups tasks for duration learning, metrics and tracing.
Sourcepub fn key(self, k: impl Into<Arc<str>>) -> Self
pub fn key(self, k: impl Into<Arc<str>>) -> Self
Unique key: deduplicates submissions and can be referenced by dependents.
Sourcepub fn deadline_in(self, d: Duration) -> Self
pub fn deadline_in(self, d: Duration) -> Self
Soft deadline, relative to submission: urgency rises as it approaches.
Sourcepub fn deadline_at(self, t: SystemTime) -> Self
pub fn deadline_at(self, t: SystemTime) -> Self
Soft deadline at a wall-clock time.
Sourcepub fn start_at(self, t: SystemTime) -> Self
pub fn start_at(self, t: SystemTime) -> Self
Start at a fixed time (default tolerance 1s, run late if missed).
Sourcepub fn start_in(self, d: Duration) -> Self
pub fn start_in(self, d: Duration) -> Self
Start this long after submission (default tolerance 1s, run late if missed).
Sourcepub fn start_tolerance(self, tol: Duration) -> Self
pub fn start_tolerance(self, tol: Duration) -> Self
How late a fixed start may begin and still count as on time (any call order).
Sourcepub fn on_miss(self, p: MissPolicy) -> Self
pub fn on_miss(self, p: MissPolicy) -> Self
What to do if the fixed start is missed (any call order).
Sourcepub fn duration_hint(self, d: Duration) -> Self
pub fn duration_hint(self, d: Duration) -> Self
Expected run time, used before the engine has learned the kind’s durations.
Sourcepub fn timeout(self, d: Duration) -> Self
pub fn timeout(self, d: Duration) -> Self
Per-attempt timeout: the attempt is aborted and retried (if allowed) when it elapses.
Sourcepub fn retry(self, r: RetryPolicy) -> Self
pub fn retry(self, r: RetryPolicy) -> Self
Retry policy (default: the pool’s).
Sourcepub fn resource(self, name: impl Into<Arc<str>>, amount: u32) -> Self
pub fn resource(self, name: impl Into<Arc<str>>, amount: u32) -> Self
Require amount units of a configured resource for each attempt.
Sourcepub fn tag(self, k: impl Into<Arc<str>>, v: impl Into<Arc<str>>) -> Self
pub fn tag(self, k: impl Into<Arc<str>>, v: impl Into<Arc<str>>) -> Self
Attach a key/value label (visible to executors and in traces).