pub struct BatchHook<T, O: Ordering = TotalOrder, R: Retries = ExactlyOnce, S = OnProcess> { /* private fields */ }Expand description
A hook handle controlling a batch operator over a stream of T elements with ordering
O and retry guarantee R (mirroring the type of the stream being batched). S is the
handle’s scope.
A decision for a batch hook says which buffered elements form the next batch released
into the tick. For an AtLeastOnce stream, decisions may also keep released elements
buffered so they are delivered again in a later batch. See hydro_lang::sim::hooks for
the decisions offered.
Implementations§
Source§impl<T, O: Ordering, R: Retries, Scope: ScriptableHookScope> BatchHook<T, O, R, Scope>
impl<T, O: Ordering, R: Retries, Scope: ScriptableHookScope> BatchHook<T, O, R, Scope>
Sourcepub fn pause(&self)
Available on crate feature sim only.
pub fn pause(&self)
sim only.Declares that buffering at this operator is intended: while paused, the hook is exempt from the missing-decision error, never causes its tick to run, and — if its tick runs anyway because other hooks feed it — contributes its “nothing new” behavior each time. Scripting any decision implicitly resumes the hook.
A pause takes its place in the script like everything else: requested while a decision is still pending, the hold begins once that decision has been consumed.
Sourcepub fn resume(&self)
Available on crate feature sim only.
pub fn resume(&self)
sim only.Ends a Self::pause (and clears Self::auto_pause mode).
Sourcepub fn auto_pause(&self)
Available on crate feature sim only.
pub fn auto_pause(&self)
sim only.Sets a standing mode where this hook only ever acts when scripted: it holds immediately, and every scripted decision leaves a fresh hold in place behind it.
This deliberately opts out of the forgotten-hook protection: if the test
forgets a step, the operator silently holds its data instead of failing. The
one auto_pause() line at the top of a test is the reviewer-visible marker
that this hook’s timing is entirely script-driven, missed steps and all.
Sourcepub async fn pause_while<Fut: Future>(&self, body: Fut) -> Fut::Output
Available on crate feature sim only.
pub async fn pause_while<Fut: Future>(&self, body: Fut) -> Fut::Output
sim only.Pauses the hook exactly for the duration of body (resuming even on panic), so
a bracketed buffering phase cannot leak a paused hook.
Sourcepub fn pause_until(
&self,
predicate: impl Fn(&BatchStatus) -> bool + Unpin,
) -> PauseUntilFuture<BatchStatus, impl Fn(&BatchStatus) -> bool + Unpin> ⓘ
Available on crate feature sim only.
pub fn pause_until( &self, predicate: impl Fn(&BatchStatus) -> bool + Unpin, ) -> PauseUntilFuture<BatchStatus, impl Fn(&BatchStatus) -> bool + Unpin> ⓘ
sim only.Pauses the hook and returns a future that resolves once the hook’s
pending-input status satisfies predicate — a synchronization point for
scripts where the right decision is not knowable upfront. The status is read
on demand at every scheduling point. After the future resolves, the hook is
unpaused; the ordinary missing-decision error applies from there on.
Sourcepub fn pause_until_count(
&self,
n: usize,
) -> PauseUntilFuture<BatchStatus, impl Fn(&BatchStatus) -> bool + Unpin> ⓘ
Available on crate feature sim only.
pub fn pause_until_count( &self, n: usize, ) -> PauseUntilFuture<BatchStatus, impl Fn(&BatchStatus) -> bool + Unpin> ⓘ
sim only.Pauses the hook and returns a future that resolves once at least n elements are
buffered; see Self::pause_until.
Source§impl<T, R: Retries, Scope: ScriptableHookScope> BatchHook<T, TotalOrder, R, Scope>
impl<T, R: Retries, Scope: ScriptableHookScope> BatchHook<T, TotalOrder, R, Scope>
Sourcepub fn release(&self, n: usize) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn release(&self, n: usize) -> DecisionFuture ⓘ
sim only.Scripts the next batch to be exactly the next n buffered elements. The tick
fires at the first moment the decision can be honored in full.
Sourcepub fn release_values(
&self,
values: impl IntoIterator<Item = T>,
) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn release_values( &self, values: impl IntoIterator<Item = T>, ) -> DecisionFuture ⓘ
sim only.Scripts the next batch to be exactly this sequence of values. Values must match the buffered prefix in order: a mismatching available value panics immediately, while a matching but incomplete prefix waits for the remaining values to arrive.
Sourcepub fn release_all(&self) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn release_all(&self) -> DecisionFuture ⓘ
sim only.Scripts the next batch to be everything that has arrived by the time the tick
fires. Under fuzzing, the released contents co-vary with the schedule being
explored; use Self::release to name them exactly.
Sourcepub fn release_empty(&self) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn release_empty(&self) -> DecisionFuture ⓘ
sim only.Scripts the next batch to be empty, holding everything buffered. Shorthand for
Self::release(0).
Source§impl<T, Scope: ScriptableHookScope> BatchHook<T, TotalOrder, AtLeastOnce, Scope>
impl<T, Scope: ScriptableHookScope> BatchHook<T, TotalOrder, AtLeastOnce, Scope>
Sourcepub fn release_keep_last(&self, n: usize) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn release_keep_last(&self, n: usize) -> DecisionFuture ⓘ
sim only.Like Self::release, but the last released element stays buffered, so it is
delivered again as the first element of the next batch.
§Panics
If n is zero.
Sourcepub fn release_values_keep_last(
&self,
values: impl IntoIterator<Item = T>,
) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn release_values_keep_last( &self, values: impl IntoIterator<Item = T>, ) -> DecisionFuture ⓘ
sim only.Like Self::release_values, but the last released element stays buffered; see
Self::release_keep_last.
§Panics
If values is empty.
Source§impl<T, R: Retries, Scope: ScriptableHookScope> BatchHook<T, NoOrder, R, Scope>
impl<T, R: Retries, Scope: ScriptableHookScope> BatchHook<T, NoOrder, R, Scope>
Sourcepub fn release_values(
&self,
values: impl IntoIterator<Item = T>,
) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn release_values( &self, values: impl IntoIterator<Item = T>, ) -> DecisionFuture ⓘ
sim only.Scripts the next batch to contain exactly this multiset of buffered values. Values are matched independently of arrival order; duplicates request the corresponding number of equal buffered items. The tick fires once every requested value exists.
Sourcepub fn release_all(&self) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn release_all(&self) -> DecisionFuture ⓘ
sim only.Scripts the next batch to be everything that has arrived by the time the tick
fires. Under fuzzing, the released contents co-vary with the schedule being
explored; use Self::release_values to name them exactly.
Sourcepub fn release_empty(&self) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn release_empty(&self) -> DecisionFuture ⓘ
sim only.Scripts the next batch to be empty, holding everything buffered. Shorthand for
Self::release_values with no values.
Source§impl<T, Scope: ScriptableHookScope> BatchHook<T, NoOrder, AtLeastOnce, Scope>
impl<T, Scope: ScriptableHookScope> BatchHook<T, NoOrder, AtLeastOnce, Scope>
Sourcepub fn release_values_keep(
&self,
values: impl IntoIterator<Item = T>,
keep: impl IntoIterator<Item = T>,
) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn release_values_keep( &self, values: impl IntoIterator<Item = T>, keep: impl IntoIterator<Item = T>, ) -> DecisionFuture ⓘ
sim only.Like Self::release_values, but the elements matching keep (a subset of
values) stay buffered, so they are delivered again in a later batch.
Source§impl<T, O: Ordering, R: Retries, C> BatchHook<T, O, R, OnCluster<C>>
impl<T, O: Ordering, R: Retries, C> BatchHook<T, O, R, OnCluster<C>>
Sourcepub fn on(&self, member_id: u32) -> BatchHook<T, O, R, OnMember<C>>
pub fn on(&self, member_id: u32) -> BatchHook<T, O, R, OnMember<C>>
Selects one cluster member’s instance of the hooked operator, returning an
OnMember-scoped handle with the full scripting API.
Each member’s instance is scripted independently: handle.on(0).release(2)
scripts member 0’s next batch and says nothing about the other members, each
of which needs its own decision (or pause) when it holds buffered input. A
member ID outside the cluster’s sizing is reported when the scripting call
is awaited.
Trait Implementations§
impl<T, O: Ordering, R: Retries, S> Copy for BatchHook<T, O, R, S>
Auto Trait Implementations§
impl<T, O, R, S> Forget for BatchHook<T, O, R, S>
impl<T, O, R, S> Freeze for BatchHook<T, O, R, S>
impl<T, O, R, S> Move for BatchHook<T, O, R, S>
impl<T, O, R, S> RefUnwindSafe for BatchHook<T, O, R, S>
impl<T, O, R, S> Send for BatchHook<T, O, R, S>
impl<T, O, R, S> Sync for BatchHook<T, O, R, S>
impl<T, O, R, S> Unpin for BatchHook<T, O, R, S>
impl<T, O, R, S> UnsafeUnpin for BatchHook<T, O, R, S>
impl<T, O, R, S> UnwindSafe for BatchHook<T, O, R, S>
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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 more