package operators
- Alphabetic
- Public
- Protected
Type Members
- final case class And[-I, +LO, +RO, +E](left: Stage[I, LO, E], right: Stage[I, RO, E]) extends BaseBinaryOperator[I, LO, RO, (LO, RO), E] with Product with Serializable
A binary operator that applies
leftandrightto the same input sequentially, producing a tuple of both outputs when both succeed.A binary operator that applies
leftandrightto the same input sequentially, producing a tuple of both outputs when both succeed.The evaluation is short-circuit on the left side:
- If
leftyieldsh8io.stages.Yield.Some,rightis applied to the same input.- If
rightalso yieldsSome, the result isYield.Some((leftOut, rightOut), ...). - If
rightyieldsNone, the result isYield.None(mergedStatus, ...).
- If
- If
leftyieldsh8io.stages.Yield.None,rightis **not** applied and the result isYield.None(leftStatus, ...).
Statuses from both sides are merged with
combine.- I
the shared input type (contravariant)
- LO
the left output type (covariant)
- RO
the right output type (covariant)
- E
the error type (covariant)
- left
the first stage to apply
- right
the second stage to apply when
leftsucceeds
- If
- final case class CompleteIfNone[I, O, E](alterand: Stage[I, O, E]) extends Decorator[I, O, E] with Product with Serializable
A decorator that stops the pipeline when the inner stage produces no output.
A decorator that stops the pipeline when the inner stage produces no output.
When the inner stage yields
h8io.stages.Yield.Nonewithh8io.stages.Status.Success,CompleteIfNoneupgrades the status toh8io.stages.Status.Complete, signaling that processing should not continue. All otherh8io.stages.Yieldvariants are forwarded unchanged (with the evolution mapped to preserve the decorator).This is useful for stages that return
Nonewhen their input stream is exhausted — wrapping them withCompleteIfNoneturns the absence of output into a clean pipeline termination.- I
the input type
- O
the output type
- E
the error type
- alterand
the inner stage to observe
- final case class IAnd[-I, +LO, +RO, +E](left: Stage[I, LO, E], right: Stage[I, RO, E]) extends BinaryOperator[Stage[I, LO, E], Stage[I, RO, E], I, (LO, RO), E] with Product with Serializable
An independent binary operator that applies two stages to the same input simultaneously and combines their outputs into a tuple.
An independent binary operator that applies two stages to the same input simultaneously and combines their outputs into a tuple.
Both
leftandrightare always applied — unlike And, which skipsrightifleftproduces no output.- If both stages yield
h8io.stages.Yield.Some, the result ish8io.stages.Yield.Some((leftOut, rightOut), mergedStatus, ...). - If either stage yields
h8io.stages.Yield.None, the result ish8io.stages.Yield.None(mergedStatus, ...).
Statuses from both stages are merged with
combine(i.e.,leftStatus.combine(rightStatus)). The evolution pairs each branch's continuations symmetrically.- I
the shared input type (contravariant)
- LO
the left output type (covariant)
- RO
the right output type (covariant)
- E
the error type (covariant)
- left
the first stage
- right
the second stage
- If both stages yield
- final case class Lift[I, O, E](alterand: Stage[I, O, E]) extends Alterator[Stage[I, O, E], I, Option[O], E] with Fruitful[I, Option[O], E] with Product with Serializable
A decorator that wraps a stage's optional output into an
Option, making the result always present.A decorator that wraps a stage's optional output into an
Option, making the result always present.- If the inner stage yields
h8io.stages.Yield.Some(v, ...),Liftproducesh8io.stages.Yield.Some(Some(v), ...). - If the inner stage yields
h8io.stages.Yield.None(...),Liftproducesh8io.stages.Yield.Some(None, ...).
Because
Liftalways emits a value, it extends h8io.stages.base.Fruitful. The evolution of the result is mapped so that every continuation stage is also wrapped inLift, preserving the lifting semantics across the entire pipeline.Liftis the inverse of h8io.stages.projections.Unlift.- I
the input type
- O
the inner output type; the outer output type becomes
Option[O]- E
the error type
- alterand
the inner stage whose output is optionally present
- If the inner stage yields
- final case class LocalSoftDeadline[-I, +O, +E](tsSupplier: () => Long, now: () => Long, duration: Long, alterand: Stage[I, O, E]) extends Decorator[I, O, E] with Product with Serializable
A decorator that stops the pipeline after a given duration has elapsed since the last successful
h8io.stages.Evolutiontransition.A decorator that stops the pipeline after a given duration has elapsed since the last successful
h8io.stages.Evolutiontransition.Unlike h8io.stages.std.GlobalSoftDeadline, which measures time from the moment the stage is created,
LocalSoftDeadlineresets its clock on everyonSuccesstransition: the timestamp is captured at eachapplycall and preserved through theonSuccesstransition, so the deadline window of the next stage starts from when the previousapplywas evaluated. OnonCompleteandonErrortransitions the clock is also reset (tonow), but the deadline is checked on the very nextapplycall.If the deadline is exceeded, the
h8io.stages.Statusof the currenth8io.stages.Yieldis upgraded to its break variant (e.g.Success→Complete) by applyingbreakto the status.If
duration ≤ 0the factory methods return h8io.stages.std.DeadEnd directly, ensuring the pipeline immediately terminates.- I
the input type (contravariant)
- O
the output type (covariant)
- E
the error type (covariant)
- tsSupplier
a thunk that returns the timestamp captured at the last
applycall- now
a supplier of the current time in nanoseconds
- duration
the time budget in nanoseconds
- alterand
the inner stage whose deadline is enforced
- final case class Loop[T, +E](alterand: Endo[T, E]) extends Decorator[T, T, E] with Product with Serializable
A decorator that feeds the output of each successful step back as the input of the next, effectively looping the inner endomorphic stage until it stops.
A decorator that feeds the output of each successful step back as the input of the next, effectively looping the inner endomorphic stage until it stops.
The tail-recursive loop works as follows:
h8io.stages.Status.Success+h8io.stages.Yield.Some: the output becomes the new input and the loop continues with theonSuccesscontinuation.h8io.stages.Status.Success+h8io.stages.Yield.None: no output was produced; the loop stops and emitsYield.None(Success, Loop(onComplete)).h8io.stages.Status.Completewith no errors: the loop stops, converts the status back toSuccess, and selects theCompletecontinuation for the next outer invocation.h8io.stages.Status.Completewith errors: the loop stops, preserves the errors, and selects theCompletecontinuation for the next outer invocation.
This makes
Loopsuitable for in-process iterative computations (e.g., fixed-point iterations) where the result of one step seeds the next.- T
the value type (both input and output)
- E
the error type (covariant)
- alterand
the inner endomorphic stage
T → Tto loop
- final case class Or[-I, +LO, +RO, +E](left: Stage[I, LO, E], right: Stage[I, RO, E]) extends BinaryOperator[Stage[I, LO, E], Stage[I, RO, E], I, Either[LO, RO], E] with Product with Serializable
A binary operator that tries
leftfirst; ifleftproduces no output, it falls back toright, wrapping the result inscala.util.Either.A binary operator that tries
leftfirst; ifleftproduces no output, it falls back toright, wrapping the result inscala.util.Either.Evaluation rules for a given input:
- If
leftyieldsh8io.stages.Yield.Some, the result isYield.Some(Left(leftOut), leftStatus, ...).rightis **not** applied. - If
leftyieldsh8io.stages.Yield.None,rightis applied:rightyieldsSome→Yield.Some(Right(rightOut), mergedStatus, ...).rightyieldsNone→Yield.None(mergedStatus, ...).
Statuses are merged with
combine.- I
the shared input type (contravariant)
- LO
the left output type (covariant)
- RO
the right output type (covariant)
- E
the error type (covariant)
- left
the preferred stage; tried first
- right
the fallback stage; tried only when
leftyields no output
- If
- final case class Repeat[-I, +O, +E](alterand: Stage[I, O, E]) extends Decorator[I, O, E] with Product with Serializable
A decorator that keeps re-applying the inner stage (following its
h8io.stages.Evolution.onSuccesstransitions) until the stage signals completion or an error.A decorator that keeps re-applying the inner stage (following its
h8io.stages.Evolution.onSuccesstransitions) until the stage signals completion or an error.The loop is implemented with
@tailrecso it does not grow the stack. The loop continues as long as the inner stage yieldsh8io.stages.Status.Success. It stops onh8io.stages.Status.Complete: if there are no errors the status is converted back toSuccess; if there are errors, theCompletestatus is preserved.Repeatis useful for driving stages like h8io.stages.std.Countdown that signal "batch complete" viaStatus.Completeand should be repeated as a whole unit.- I
the input type (contravariant)
- O
the output type (covariant)
- E
the error type (covariant)
- alterand
the inner stage to repeat
- final case class Safe[-I, +O, +E](alterand: Stage[I, O, E]) extends Alterator[Stage[I, O, E], I, O, Either[Throwable, E]] with SafeStage[I, O, Either[Throwable, E]] with Product with Serializable
A decorator that catches non-fatal exceptions thrown by the inner stage and converts them into
h8io.stages.Status.Completeerror values.A decorator that catches non-fatal exceptions thrown by the inner stage and converts them into
h8io.stages.Status.Completeerror values.The error type is widened from
EtoEither[Throwable, E]:- Errors already carried by the inner stage are wrapped as
Right(e). - Exceptions caught during
applyare reported asLeft(throwable)in aYield.None(Status.error(Left(e)), this).
Only non-fatal exceptions (matched by
scala.util.control.NonFatal) are caught; fatal errors such asOutOfMemoryErrorpropagate normally.The evolution is mapped so that every continuation stage remains wrapped in
Safe, maintaining exception safety across the entire pipeline.- I
the input type (contravariant)
- O
the output type (covariant)
- E
the original error type of the inner stage (covariant)
- alterand
the inner stage whose exceptions should be caught
- Errors already carried by the inner stage are wrapped as
Value Members
- object And extends Serializable
Companion object for And.
- object CompleteIfSome extends Decoration[Any, Any, Nothing]
A h8io.stages.base.Decoration that stops the pipeline as soon as the decorated stage produces an output value.
A h8io.stages.base.Decoration that stops the pipeline as soon as the decorated stage produces an output value.
CompleteIfSomeappends h8io.stages.std.Complete after the decorated stage via~>. If the stage yieldsh8io.stages.Yield.Some,Completeimmediately emitsh8io.stages.Status.Complete, terminating the pipeline. If the stage yieldsh8io.stages.Yield.None,Completeis not reached and the pipeline continues normally.The singleton operates on
Stage[Any, Any, Nothing]and can be cast to any concreteDecoration[I, O, E]viaapply[I, O, E].Example:
val stage: Stage[Int, Int, Nothing] = ... val completing: Stage[Int, Int, Nothing] = CompleteIfSome(stage) // Once stage produces a value, the pipeline stops.
- object IAnd extends Serializable
Companion object for IAnd.
- object Identity extends Decoration[Any, Nothing, Nothing]
The identity h8io.stages.base.Decoration: returns the decorated stage unchanged.
The identity h8io.stages.base.Decoration: returns the decorated stage unchanged.
Identityis useful as a no-op placeholder in decoration pipelines or when a h8io.stages.base.Decoration is required by an API but no transformation is needed.The singleton operates on
Stage[Any, Nothing, Nothing]and can be safely cast to any concreteDecoration[I, O, E]viaapply[I, O, E].Example:
val dec: Decoration[String, Int, Nothing] = Identity[String, Int, Nothing]
- object KeepLastOutput
A decorator that remembers the last output produced by the inner stage and re-emits it when the inner stage yields no value.
A decorator that remembers the last output produced by the inner stage and re-emits it when the inner stage yields no value.
The decorator has two internal states:
- **
Nonestate** (initial): no output has been seen yet. The inner stage'sh8io.stages.Yield.Noneis forwarded unchanged; ah8io.stages.Yield.Someis forwarded and transitions the wrapper to theSomestate. - **
Somestate**: a previous outputoutis remembered. On every subsequent call the inner stage's last known output is emitted regardless of whether the inner stage yieldsSomeorNone. A newh8io.stages.Yield.Someupdates the remembered value.
In both states the evolution is mapped so that continuations remain wrapped in the appropriate
KeepLastOutputvariant, preserving the last-value semantics.The
applyfactory method always starts in theNonestate. - **
- object LocalSoftDeadline extends Serializable
Companion object and factory for LocalSoftDeadline.
- object Or extends Serializable
Companion object for Or.