Durable.Definition.Step (Durable v0.1.0-rc)

View Source

Represents a single step in a workflow.

Pipeline Model

Steps use a pure pipeline model where data flows from step to step:

  • Each step receives one argument: the data from the previous step
  • First step receives the workflow input
  • Each step returns {:ok, data} or {:error, reason}

The body_fn field contains the step function that processes data.

Summary

Functions

Executes the step with the given data.

Types

retry_opts()

@type retry_opts() :: %{
  optional(:max_attempts) => pos_integer(),
  optional(:backoff) => :exponential | :linear | :constant,
  optional(:base) => pos_integer(),
  optional(:max_backoff) => pos_integer()
}

step_type()

@type step_type() :: :step | :decision | :branch | :parallel | :loop | :switch

t()

@type t() :: %Durable.Definition.Step{
  body_fn: (map() -> {:ok, map()} | {:error, term()}) | nil,
  module: module(),
  name: atom(),
  opts: %{
    optional(:retry) => retry_opts(),
    optional(:timeout) => pos_integer(),
    optional(:compensate) => atom(),
    optional(:queue) => atom()
  },
  type: step_type()
}

Functions

execute(step, data)

Executes the step with the given data.

For pipeline model steps, calls body_fn.(data).