package stages
- Alphabetic
- Public
- Protected
Package Members
- package base
Type aliases used throughout the
libmodule for describing stage transformations.Type aliases used throughout the
libmodule for describing stage transformations.// A decorator wraps a Stage[I, O, E] and returns another Stage[I, O, E]: val myDecorator: Decorator[String, Int, Nothing] = BreakIfNone(_) // An alteration converts any Stage to a (possibly different) Stage: val myAlt: Alteration[Stage[String, Int, Nothing], Stage[String, Option[Int], Nothing]] = Lift(_)
- package cats
- package examples
- package operators
- package projections
- package std
Type Members
- trait Evolution[-I, +O, +E] extends AnyRef
A strategy that selects the next Stage to use when the pipeline is ready to re-process, based on the Status carried by the Yield returned from the most recent stage application.
A strategy that selects the next Stage to use when the pipeline is ready to re-process, based on the Status carried by the Yield returned from the most recent stage application. In a composed pipeline, this refers to the combined
Yieldproduced for the current input.Every Yield carries an
Evolutionthat has three branches:- onSuccess — invoked when the previous stage succeeded (Status.Success).
- onComplete — invoked when the pipeline signalled normal completion (Status.Complete).
- onError — invoked when one or more errors were accumulated (Status.Error).
The branch is selected by
Status.applyinside Stage.execute, so callers never need to dispatch on the status themselves.Evolutionis contravariant inIand covariant inOandE, mirroring the variance of the Stage values it returns.- I
the input type consumed by the returned stages (contravariant)
- O
the output type produced by the returned stages (covariant)
- E
the error type (covariant)
- sealed trait Outcome[+O, +E] extends AnyRef
The final result of executing a Stage via Stage.execute.
The final result of executing a Stage via Stage.execute.
Unlike Yield, an
Outcomedoes not carry an Evolution; it is the terminal value returned to the caller after the pipeline has finished processing a single input. The Status indicates whether execution succeeded, completed, or produced errors. If disposing the selected next stage fails, the exception is recorded in Outcome.disposeFailure without preventing the outcome from being returned.- O
the output type (covariant)
- E
the error type (covariant)
- trait Stage[-I, +O, +E] extends (I) => Yield[I, O, E]
A single processing unit in a pipeline that transforms input values into Yield results.
A single processing unit in a pipeline that transforms input values into Yield results.
A
Stageproduces a Yield that carries an optional output of typeO, a Status, and an Evolution strategy describing how to continue processing.Stages are contravariant in
Iand covariant in bothOandE, which allows them to be composed safely in a pipeline via the ~> operator.Lifecycle
Every
Stageinstance participates in exactly one of these lifecycle paths during a pipeline run:- Active: apply is called with an input value. The stage processes it and returns a Yield.
- Skipped: skip is called when the stage is bypassed — for example, because an upstream stage produced no output, or because of a non-inclusive binary operation. The stage must return its Evolution without performing any processing.
- Disposed: dispose is called when the pipeline is torn down. All stages in the pipeline receive this call, regardless of whether they were active or skipped.
Exactly one of apply or skip is called per pipeline run; dispose is called once when the pipeline is released. Fatal exceptions are not accounted for by this contract.
Example — building a pipeline:
val parse: Stage[String, Int, String] = ... val double: Stage[Int, Int, String] = ... val pipeline: Stage[String, Int, String] = parse ~> double
- I
the input type (contravariant)
- O
the output type (covariant)
- E
the error type (covariant)
- sealed trait Status[+E] extends AnyRef
The execution status produced by a Stage.
The execution status produced by a Stage.
A
Statustravels alongside the output (or absence of output) in a Yield and is accumulated as stages are composed. There are three possible states:- Status.Success — the stage completed normally and processing may continue.
- Status.Complete — the pipeline has finished successfully; no further input should be processed.
- Status.Error — one or more errors occurred; the pipeline should stop and report them.
Statuses form a semigroup under the internal
++operation used when merging the results of composed stages:Successis the identity element,CompletedominatesSuccessbut yields toError, andErrordominates all.- E
the error type (covariant)
- sealed trait Yield[-I, +O, +E] extends AnyRef
The immediate result returned by a Stage when applied to an input value.
The immediate result returned by a Stage when applied to an input value.
A
Yieldcarries three pieces of information:- An optional output value (
O), present only in Yield.Some. - A Status representing the outcome of this stage invocation.
- An Evolution that decides which stage to use when re-processing based on the status.
The type parameters follow the same variance rules as Stage: contravariant in
I(the input consumed by the continuation stages stored in the evolution) and covariant inOandE.- I
the input type consumed by the Evolution stages (contravariant)
- O
the output type (covariant)
- E
the error type (covariant)
- An optional output value (
Value Members
- object Outcome
Companion object containing the two concrete variants of Outcome.
- object Stage
Companion object for Stage, containing type aliases and the AndThen implementation.
- object Status
Companion object containing the three concrete status variants.
- object Yield
Companion object containing the two concrete variants of Yield.