pub struct BulkCtx<T> {
pub input: T,
pub batch_id: String,
pub key: String,
pub run_id: String,
pub headers: HashMap<String, String>,
/* private fields */
}Expand description
Per-item execution context handed to Pipeline::run.
Wraps the typed input together with the durable per-item memo, a cost accumulator, the run’s cooperative cancellation token, the delivery’s lease handle, the item’s staged KV effects and read access to the caller KV namespace.
Fields§
§input: TThe deserialized input item for this run.
batch_id: StringThe batch this item belongs to.
key: StringThe item’s key: the value of
BulkBuilder::key_fn for the
input, or the positional item-{i} default.
run_id: StringThe workflow run identifier of this item, derived from the batch id and the key.
headers: HashMap<String, String>Submitter-supplied metadata threaded through from the bulk run.
Implementations§
Source§impl<T> BulkCtx<T>
impl<T> BulkCtx<T>
Sourcepub fn memo(&self) -> &Memo
pub fn memo(&self) -> &Memo
The item’s durable memo. Wrap each expensive phase of
Pipeline::run in Memo::memoized or
Memo::memoized_by_content so a retried item reads the completed
phases back. Calls to record_cost inside a
memoized future run only when the future runs; use
memoized_with_cached_cost when
memoized results must also contribute to the cost report.
Sourcepub async fn memoized_with_cached_cost<R, F, E>(
&self,
key: &str,
f: F,
) -> Result<R, E>where
R: Serialize + DeserializeOwned,
F: Future<Output = Result<(R, CostReport), E>>,
E: From<Error>,
pub async fn memoized_with_cached_cost<R, F, E>(
&self,
key: &str,
f: F,
) -> Result<R, E>where
R: Serialize + DeserializeOwned,
F: Future<Output = Result<(R, CostReport), E>>,
E: From<Error>,
Run f once and memoize both its value and counters under key,
or return the memoized value and replay its counters on a retry.
f returns (value, cost), and the counters are recorded after
memoization returns, so they are included whether the phase runs or
reads its memo entry.
Sourcepub async fn memoized_by_content_with_cached_cost<K, R, F, E>(
&self,
input: &K,
f: F,
) -> Result<R, E>where
K: Serialize + ?Sized,
R: Serialize + DeserializeOwned,
F: Future<Output = Result<(R, CostReport), E>>,
E: From<Error>,
pub async fn memoized_by_content_with_cached_cost<K, R, F, E>(
&self,
input: &K,
f: F,
) -> Result<R, E>where
K: Serialize + ?Sized,
R: Serialize + DeserializeOwned,
F: Future<Output = Result<(R, CostReport), E>>,
E: From<Error>,
Self::memoized_with_cached_cost under Memo::content_key of
input.
Sourcepub fn record_cost(&self, metric: &str, amount: f64)
pub fn record_cost(&self, metric: &str, amount: f64)
Add amount to the cost counter named metric for this item. The
per-item totals roll up into the batch-level
ProgressSnapshot and
BulkReport.
Sourcepub fn cancel_token(&self) -> &CancellationToken
pub fn cancel_token(&self) -> &CancellationToken
The run’s cooperative cancellation token. Watch it to short-circuit a
long-running step when the bulk run is draining (e.g. on spot
preemption); see crate::Step::cancel_token.
Sourcepub fn lease(&self) -> &LeaseHandle
pub fn lease(&self) -> &LeaseHandle
The lease handle for this item’s delivery. A long-running
pipeline calls LeaseHandle::ensure_at_least at progress
points (or once, with a slow call’s timeout, before issuing it)
so the item is not re-queued while it still runs; see
crate::Step::lease.
Sourcepub fn effects(&self) -> &EffectsHandle
pub fn effects(&self) -> &EffectsHandle
The item’s staged application KV effects. Writes and deletes
staged here are applied atomically with the item’s successful
completion; an item that fails applies nothing, and a staged
value must be correct when applied more than once, since
delivery is at-least-once. See EffectsHandle for the
staging rules.
Auto Trait Implementations§
impl<T> !Freeze for BulkCtx<T>
impl<T> !RefUnwindSafe for BulkCtx<T>
impl<T> !UnwindSafe for BulkCtx<T>
impl<T> Send for BulkCtx<T>where
T: Send,
impl<T> Sync for BulkCtx<T>where
T: Sync,
impl<T> Unpin for BulkCtx<T>where
T: Unpin,
impl<T> UnsafeUnpin for BulkCtx<T>where
T: UnsafeUnpin,
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> 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);