pub struct OrderingHook<T, B: Boundedness = Unbounded, R: Retries = ExactlyOnce, S = OnProcess> { /* private fields */ }Expand description
A hook handle controlling an assume_ordering operator over T elements, with retry
guarantee R (mirroring the type of the stream whose ordering is assumed). S is the
handle’s scope.
For an ExactlyOnce stream, a top-level decision selects the next buffered element to
release, and an assume_ordering inside a tick instead takes one exhaustive ordering
of that tick’s complete input. For an AtLeastOnce stream, ordering additionally
decides which slots each element’s retries occupy, so top-level decisions split into
emit (release a slot, keep the element for re-emission) and emit_final (release
the element’s last slot), and the in-tick ordering may emit each element into several
slots. See hydro_lang::sim::hooks for the decisions offered.
Implementations§
Source§impl<T, Scope: ScriptableHookScope> OrderingHook<T, Unbounded, ExactlyOnce, Scope>where
T: Serialize + DeserializeOwned,
impl<T, Scope: ScriptableHookScope> OrderingHook<T, Unbounded, ExactlyOnce, Scope>where
T: Serialize + DeserializeOwned,
Sourcepub fn next(&self, value: T) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn next(&self, value: T) -> DecisionFuture ⓘ
sim only.Scripts a top-level assume_ordering action to release the buffered element equal
to value. Exactly one element is released, preserving opportunities for ticks and
feedback to interleave with the remaining buffered input.
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(&OrderingStatus) -> bool + Unpin,
) -> PauseUntilFuture<OrderingStatus, impl Fn(&OrderingStatus) -> bool + Unpin> ⓘ
Available on crate feature sim only.
pub fn pause_until( &self, predicate: impl Fn(&OrderingStatus) -> bool + Unpin, ) -> PauseUntilFuture<OrderingStatus, impl Fn(&OrderingStatus) -> 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<OrderingStatus, impl Fn(&OrderingStatus) -> bool + Unpin> ⓘ
Available on crate feature sim only.
pub fn pause_until_count( &self, n: usize, ) -> PauseUntilFuture<OrderingStatus, impl Fn(&OrderingStatus) -> bool + Unpin> ⓘ
sim only.Pauses a top-level ordering hook until at least n elements are buffered; see
Self::pause_until.
Source§impl<T, Scope: ScriptableHookScope> OrderingHook<T, Bounded, ExactlyOnce, Scope>where
T: Serialize + DeserializeOwned,
impl<T, Scope: ScriptableHookScope> OrderingHook<T, Bounded, ExactlyOnce, Scope>where
T: Serialize + DeserializeOwned,
Sourcepub fn order(&self, values: impl IntoIterator<Item = T>) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn order(&self, values: impl IntoIterator<Item = T>) -> DecisionFuture ⓘ
sim only.Scripts an in-tick assume_ordering observation to consume its complete input in
exactly this order. The supplied values must be a permutation of all values received
by the operator during that tick.
Source§impl<T, Scope: ScriptableHookScope> OrderingHook<T, Unbounded, AtLeastOnce, Scope>where
T: Serialize + DeserializeOwned,
impl<T, Scope: ScriptableHookScope> OrderingHook<T, Unbounded, AtLeastOnce, Scope>where
T: Serialize + DeserializeOwned,
Sourcepub fn emit(&self, value: T) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn emit(&self, value: T) -> DecisionFuture ⓘ
sim only.Scripts a top-level assume_ordering action on an at-least-once stream to release
one slot for the value value, keeping it buffered: later decisions may
emit it again (a delayed redelivery, still AtLeastOnce), after other elements
have taken slots in between.
The value remains pending input, so the script must eventually retire it with
Self::emit_final (or declare the buffering with the pause family). The
immediately-following decision may name the same value again only when two or
more buffered elements share it (the adjacent slots then belong to different
elements): a sole element in adjacent slots would be a redundant duplicate —
adjacent duplicate slots denote the same at-least-once collection, and per-slot
cardinality belongs to the downstream assume_retries observation.
Sourcepub fn emit_final(&self, value: T) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn emit_final(&self, value: T) -> DecisionFuture ⓘ
sim only.Scripts a top-level assume_ordering action on an at-least-once stream to release
the last slot for the value value, consuming every buffered element equal
to it (the script names values, not individual elements, so retirement is
value-level). Because each buffered element must occupy at least one slot,
retiring a value that several buffered elements share requires enough prior
Self::emits: k equal buffered elements need at least k slots in total. A
value that was never emitted before simply occupies a single slot.
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(&OrderingStatus) -> bool + Unpin,
) -> PauseUntilFuture<OrderingStatus, impl Fn(&OrderingStatus) -> bool + Unpin> ⓘ
Available on crate feature sim only.
pub fn pause_until( &self, predicate: impl Fn(&OrderingStatus) -> bool + Unpin, ) -> PauseUntilFuture<OrderingStatus, impl Fn(&OrderingStatus) -> 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<OrderingStatus, impl Fn(&OrderingStatus) -> bool + Unpin> ⓘ
Available on crate feature sim only.
pub fn pause_until_count( &self, n: usize, ) -> PauseUntilFuture<OrderingStatus, impl Fn(&OrderingStatus) -> bool + Unpin> ⓘ
sim only.Pauses a top-level ordering hook until at least n elements are buffered; see
Self::pause_until.
Source§impl<T, Scope: ScriptableHookScope> OrderingHook<T, Bounded, AtLeastOnce, Scope>where
T: Serialize + DeserializeOwned,
impl<T, Scope: ScriptableHookScope> OrderingHook<T, Bounded, AtLeastOnce, Scope>where
T: Serialize + DeserializeOwned,
Sourcepub fn order(&self, values: impl IntoIterator<Item = T>) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn order(&self, values: impl IntoIterator<Item = T>) -> DecisionFuture ⓘ
sim only.Scripts an in-tick assume_ordering observation on an at-least-once stream to
consume its complete input in exactly this slot sequence. Every value received by
the operator during that tick must be emitted into at least one slot, and a value
may occupy several non-adjacent slots — each extra slot is a delayed
redelivery, still AtLeastOnce. Only received values may appear, and adjacent
equal slots are accepted only when the tick received at least two equal instances
of that value (a sole instance in adjacent slots would be a redundant duplicate —
per-slot cardinality belongs to the downstream assume_retries).
Source§impl<T, B: Boundedness, R: Retries, C> OrderingHook<T, B, R, OnCluster<C>>
impl<T, B: Boundedness, R: Retries, C> OrderingHook<T, B, R, OnCluster<C>>
Sourcepub fn on(&self, member_id: u32) -> OrderingHook<T, B, R, OnMember<C>>
pub fn on(&self, member_id: u32) -> OrderingHook<T, B, 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§
Source§impl<T, B: Boundedness, R: Retries, S> Clone for OrderingHook<T, B, R, S>
impl<T, B: Boundedness, R: Retries, S> Clone for OrderingHook<T, B, R, S>
impl<T, B: Boundedness, R: Retries, S> Copy for OrderingHook<T, B, R, S>
Source§impl<T, B: Boundedness, R: Retries, S> Debug for OrderingHook<T, B, R, S>
impl<T, B: Boundedness, R: Retries, S> Debug for OrderingHook<T, B, R, S>
Source§impl<T, B: Boundedness, S: BindableHookScope> SimHook for OrderingHook<T, B, ExactlyOnce, S>
impl<T, B: Boundedness, S: BindableHookScope> SimHook for OrderingHook<T, B, ExactlyOnce, S>
Source§impl<T, B: Boundedness, S: BindableHookScope> SimHook for OrderingHook<T, B, AtLeastOnce, S>
impl<T, B: Boundedness, S: BindableHookScope> SimHook for OrderingHook<T, B, AtLeastOnce, S>
Auto Trait Implementations§
impl<T, B, R, S> Freeze for OrderingHook<T, B, R, S>
impl<T, B, R, S> RefUnwindSafe for OrderingHook<T, B, R, S>
impl<T, B, R, S> Send for OrderingHook<T, B, R, S>
impl<T, B, R, S> Sync for OrderingHook<T, B, R, S>
impl<T, B, R, S> Unpin for OrderingHook<T, B, R, S>
impl<T, B, R, S> UnsafeUnpin for OrderingHook<T, B, R, S>
impl<T, B, R, S> UnwindSafe for OrderingHook<T, B, 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> ⓘ
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