View Source Babel.Pipeline (Babel v1.1.0)

Represents a sequence of Babel.Steps (or nested Babel.Pipelines) that get evaluated sequentially, when a step fails the pipeline stops and - if set - invokes the on_error handler in an attempt to recover from the error.

Pipelines can be chained together (using chain/2). Babel will try to simplify pipeline chains by merging pipelines without distinct names and no error handling.

Summary

Types

A term describing what this pipeline does

t()

Functions

Combines a Babel.Pipeline either with another Babel.Pipeline or a list of steps. Passing another Babel.Pipeline might lead both pipelines being merged into one larger Babel.Pipeline.

Types

@type name() :: Babel.name()

A term describing what this pipeline does

@type on_error() :: on_error(term())
@type on_error(output) :: (Babel.Error.t() -> Babel.Step.result_or_trace(output))
@type step() :: Babel.Applicable.t()
@type t() :: t(any(), any())
@type t(output) :: t(any(), output)
@type t(_input, output) :: %Babel.Pipeline{
  name: name(),
  on_error: nil | on_error(output),
  reversed_steps: [step()]
}

Functions

Link to this function

apply(pipeline, context)

View Source
@spec apply(t(input, output), Babel.Context.t(input)) :: Babel.Trace.t(output)
when input: any(), output: any()
@spec chain(t(input, in_between), t(in_between, output)) :: t(input, output)
when input: any(), in_between: any(), output: any()
@spec chain(t(), [step()]) :: t()
@spec chain(t(), step()) :: t()

Combines a Babel.Pipeline either with another Babel.Pipeline or a list of steps. Passing another Babel.Pipeline might lead both pipelines being merged into one larger Babel.Pipeline.

Merging

When all of the following conditions match two Babel.Pipelines get merged:

  1. at least one pipeline has no name or both names are equal
  2. at least one pipeline has no on_error handler

In all other cases the second Babel.Pipeline will be included as a step of the first Babel.Pipeline.

Link to this function

new(name \\ nil, on_error \\ nil, step_or_steps)

View Source
@spec new(name() | nil, on_error() | nil, step() | [step()]) :: t()
Link to this function

on_error(pipeline, on_error)

View Source
@spec on_error(t(), on_error()) :: t()