Packages

  • package root
    Definition Classes
    root
  • package h8io
    Definition Classes
    root
  • package stages
    Definition Classes
    h8io
  • package base

    Type aliases used throughout the lib module for describing stage transformations.

    Type aliases used throughout the lib module 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(_)
    Definition Classes
    stages
  • package cats
    Definition Classes
    stages
  • package examples
    Definition Classes
    stages
  • package operators
    Definition Classes
    stages
  • package projections
    Definition Classes
    stages
  • package std
    Definition Classes
    stages
  • Evolution
  • Outcome
  • Stage
  • Status
  • Yield

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 Stage produces a Yield that carries an optional output of type O, a Status, and an Evolution strategy describing how to continue processing.

Stages are contravariant in I and covariant in both O and E, which allows them to be composed safely in a pipeline via the ~> operator.

Lifecycle

Every Stage instance 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)

Source
Stage.scala
Linear Supertypes
(I) => Yield[I, O, E], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Stage
  2. Function1
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def apply(in: I): Yield[I, O, E]

    Applies this stage to the given input, producing a Yield.

    Applies this stage to the given input, producing a Yield.

    in

    the input value

    returns

    a Yield containing the optional output, status, and evolution

    Definition Classes
    Stage → Function1
  2. abstract def skip(): Evolution[I, O, E]

    Returns the Evolution for this stage without processing any input.

    Returns the Evolution for this stage without processing any input.

    Any stage that participates in a pipeline run but does not process the current input must call skip() instead of apply. Common triggers: an upstream stage produced no output (Yield.None), or a non-inclusive binary operation excluded this branch. The stage must return its Evolution as it would have appeared had it run, but must not perform any side effects or consume input.

    See the Lifecycle section in Stage for the full contract.

    returns

    the Evolution representing how the pipeline should continue from this stage

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def andThen[A](g: (Yield[I, O, E]) => A): (I) => A
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
  7. def compose[A](g: (A) => I): (A) => Yield[I, O, E]
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  10. final def execute(in: I): Outcome[O, E]

    Executes this stage end-to-end and returns a plain Outcome.

    Executes this stage end-to-end and returns a plain Outcome.

    Internally this method:

    1. Applies the stage to in, obtaining a Yield.
    2. Disposes the Evolution carried by the Yield — since execute is a terminal operation, the continuation is not needed and the resources held by this stage must be released immediately.
    3. Wraps the result in an Outcome.Some or Outcome.None.

    Disposal failures do not prevent the result from being returned. Any non-fatal exception raised by Evolution.dispose is captured in Outcome.disposeFailure and the outcome is still produced. Fatal exceptions are not caught and will propagate.

    in

    the input value

    returns

    Outcome.Some if this stage produced an output, Outcome.None otherwise

    Annotations
    @inline()
  11. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  17. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  18. def toString(): String
    Definition Classes
    Function1 → AnyRef → Any
  19. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  20. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  21. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  22. final def ~>[_O, _E >: E](that: Stage[O, _O, _E]): Stage[I, _O, _E]

    Composes this stage with that, producing a new stage that feeds the output of this stage into that.

    Composes this stage with that, producing a new stage that feeds the output of this stage into that.

    The resulting Stage.AndThen feeds the output of this stage into that. If this stage produces an output, the statuses and evolutions of both stages are merged; if it produces no output, only the evolutions are composed and that is not invoked for the current input.

    _O

    the output type of the composed pipeline

    _E

    the combined error type (must be a supertype of E)

    that

    the stage to execute after this one

    returns

    a composed stage this ~> that

    Annotations
    @inline()

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from (I) => Yield[I, O, E]

Inherited from AnyRef

Inherited from Any

Ungrouped