pub struct Delivery {
pub run_id: RunId,
pub headers: HashMap<String, String>,
pub job_id: String,
pub attempts: u32,
pub max_attempts: u32,
pub cancel_token: CancellationToken,
pub lease: LeaseHandle,
pub memo: Memo,
pub run_memo: Memo,
pub effects: EffectsHandle,
pub kv: KvReadHandle,
}Expand description
The delivery a handler runs under: the identity of the run and of
the queue job delivering it, the attempt count and the delivery’s
handles. Step and jobs::JobContext
dereference to it. It holds handles only; no queue is reachable
through it.
Constructed by the runtime. A test constructs one with
Delivery::detached and assigns the fields it needs.
Fields§
§run_id: RunIdCaller-visible run identifier (the value passed to or generated by
crate::RunSpec).
headers: HashMap<String, String>Submitter-supplied metadata, threaded through every step of the run.
Reserved workflow.* headers are stripped before the handler sees them.
job_id: StringThe Taquba job ID of this delivery, useful for tracing.
attempts: u32How many times Taquba has attempted this delivery. 1 on the
first attempt; >1 after a lease expiry / nack retry.
max_attempts: u32The attempt limit: a transient failure on the attempt numbered
max_attempts ends the run.
cancel_token: CancellationTokenCooperative cancellation signal for the run. The runtime cancels
this token when crate::WorkflowRuntime::cancel is called while
this delivery is in flight, so a long-running handler (e.g. an LLM
call, a slow HTTP request) can short-circuit instead of running to
completion. Typical use:
tokio::select! {
out = do_slow_work(step) => out,
_ = step.cancel_token.cancelled() => {
Ok(StepOutcome::Cancel { reason: "cooperative".into() })
}
}Handlers that ignore the token remain correct: the runtime still
discards the outcome of a cancelled step and fires the terminal
hook with crate::TerminalStatus::Cancelled. Watching the token
only reduces cancellation latency for slow steps; it doesn’t
change semantics.
The token is a child of the claim’s cancellation token. A
re-delivery of this step observes is_cancelled() == true
immediately, because the queue re-fires the claim’s cancellation
token from the job’s persisted cancellation. Cancelling this token
leaves the claim’s token uncancelled, so the runtime does not treat
the step as externally cancelled.
lease: LeaseHandleThe lease handle of this delivery. A long-running handler calls
LeaseHandle::ensure_at_least at progress points (or once,
with a slow call’s timeout, before issuing it) so the step is
not re-queued while it still runs. A detached handle’s calls
succeed without effect.
memo: MemoPer-step durable key-value store, scoped to this step’s
(run_id, step_number). Use to memoize expensive within-step
side effects (LLM calls, paid APIs) so an at-least-once retry
of this step doesn’t re-pay for work the prior attempt already
did:
let response = match step.memo.get("llm").await? {
Some(cached) => deserialize(&cached),
None => {
let fresh = llm.complete(&prompt).await?;
step.memo.put("llm", &serialize(&fresh)).await?;
fresh
}
};See Memo for the full API.
run_memo: MemoRun-scoped durable key-value store, shared by every step of the
run. Entries live beside the per-step Delivery::memo entries
and are removed with them when the run’s retention expires. Use
it for values a later step reads back, such as an accumulating
journal; the durable channel for the next step’s input is
StepOutcome::Continue’s payload.
effects: EffectsHandleApplication KV effects for this step. Writes and deletes staged here are applied in the same transaction as the settlement that commits the returned outcome, so application state cannot diverge from the run’s transition on a crash:
step.effects.put(format!("app/runs/{}", step.run_id), b"done".to_vec())?;
Ok(StepOutcome::Succeed { result })See EffectsHandle for the staging rules.
kv: KvReadHandleRead access to the caller KV namespace. A committed value (an earlier
step’s applied effect, a crate::RunSpec::effects write, a direct
taquba::Queue::kv_put) is readable here. Effects staged by this step
become readable only after it settles. The intended use is a
read-then-stage marker check:
if step.kv.get(b"app/indexed/doc-1").await?.is_none() {
index_document(&step.payload).await?; // idempotent
step.effects.put("app/indexed/doc-1", b"1".to_vec())?;
}See KvReadHandle for the read semantics.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Delivery
impl !UnwindSafe for Delivery
impl Freeze for Delivery
impl Send for Delivery
impl Sync for Delivery
impl Unpin for Delivery
impl UnsafeUnpin for Delivery
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);