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] = CompleteIfNone(_) // 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
Evolutionwhoseevolvemethod selects the next stage based on the current Status. The appropriate stage is selected based on the Yield.status — callers useYield.evolverather than dispatching on the status directly.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 (Status.Success) or completed (Status.Complete), with or without accumulated errors. If disposing the evolution 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.
Exactly one of apply or skip is called per pipeline run. Resource cleanup is the responsibility of the Evolution returned from either call: Evolution.dispose releases the resources held by this stage, and after that call the stage must be considered unusable. 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 two possible states:- Status.Success — the stage completed normally and processing may continue.
- Status.Complete — a unit of work has finished. Passed to Evolution when selecting the next continuation
stage; enclosing alterators such as
LooporRepeatuse it to end the current cycle. Whenerrorsis empty this represents clean completion; whenerrorsis non-empty it carries one or more accumulated errors.
Statuses form a semigroup under
combine, used when merging the results of composed stages:Successis the identity element andCompleteaccumulates errors on combination.- 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 Evolution
- 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 concrete status variants.
- object Yield
Companion object containing the two concrete variants of Yield.