Jido.Action.Output (Jido Action v3.0.0-beta.12)

View Source

Explicit envelope for successful Action outputs that are not normal maps.

Normal Action success values are map-shaped and validated by the Action's output_schema. Use this envelope only when a successful Action must return a raw, stream, batch, or opaque value intentionally.

Jido.Action.Output.raw("complete")
Jido.Action.Output.batch([%{id: 1}, %{id: 2}])
Jido.Action.Output.stream(Stream.map(1..3, & &1))
Jido.Action.Output.opaque(reference, meta: %{owner: "worker"})

Effects are optional and separate from the output value:

{:ok, Jido.Action.Output.stream(stream)}
{:ok, Jido.Action.Output.stream(stream), requests}

requests is a proper list of effects for the caller. Exec does not consume the stream or dispatch the requests. Output metadata is data, not effects.

Summary

Functions

Builds an explicit batch output envelope.

Builds an explicit opaque output envelope.

Builds an explicit raw output envelope.

Builds an explicit stream output envelope.

Types

kind()

@type kind() :: :raw | :stream | :batch | :opaque

t()

@type t() :: %Jido.Action.Output{
  kind: :raw | :stream | :batch | :opaque,
  meta: map(),
  value: any()
}

Functions

batch(values, opts \\ [])

@spec batch(
  list(),
  keyword()
) :: t()

Builds an explicit batch output envelope.

opaque(value, opts \\ [])

@spec opaque(
  term(),
  keyword()
) :: t()

Builds an explicit opaque output envelope.

raw(value, opts \\ [])

@spec raw(
  term(),
  keyword()
) :: t()

Builds an explicit raw output envelope.

stream(enumerable, opts \\ [])

@spec stream(
  Enumerable.t(),
  keyword()
) :: t()

Builds an explicit stream output envelope.