Durable.Storage.Schemas.WorkflowExecution (Durable v2.0.2)

View Source

Ecto schema for workflow execution records.

Each workflow execution represents a single run of a workflow, tracking its status, context, and progress through steps.

Summary

Functions

Creates a changeset for inserting a new workflow execution.

Statuses of a finished run.

Creates a changeset for marking workflow as compensated (all compensations succeeded).

Creates a changeset for marking workflow as compensating.

Creates a changeset for marking workflow compensation as failed.

Creates a changeset for locking a workflow for execution.

Statuses of a run that's still going: it always keeps its key.

The statuses a key's holder can be in for a new start to take the key under policy. Open holders never give it up.

The reuse: policies a workflow can declare.

Creates a changeset for updating workflow status.

Types

status()

@type status() ::
  :pending
  | :running
  | :completed
  | :failed
  | :waiting
  | :cancelled
  | :compensating
  | :compensated
  | :compensation_failed

t()

@type t() :: %Durable.Storage.Schemas.WorkflowExecution{
  __meta__: term(),
  compensated_at: DateTime.t() | nil,
  compensation_results: [map()],
  completed_at: DateTime.t() | nil,
  context: map(),
  current_step: String.t() | nil,
  deadline_at: term(),
  engine_state: map(),
  error: map() | nil,
  holds_key: boolean(),
  home_queue: String.t() | nil,
  id: Ecto.UUID.t(),
  input: map(),
  inserted_at: DateTime.t(),
  key: String.t() | nil,
  lock_token: term(),
  locked_at: DateTime.t() | nil,
  locked_by: String.t() | nil,
  parent_workflow_id: Ecto.UUID.t() | nil,
  pending_inputs: term(),
  priority: integer(),
  queue: String.t(),
  retried_at: DateTime.t() | nil,
  root_workflow_id: Ecto.UUID.t() | nil,
  runs_after_id: Ecto.UUID.t() | nil,
  scheduled_at: DateTime.t() | nil,
  started_at: DateTime.t() | nil,
  status: status(),
  step_executions: term(),
  tags: [String.t()],
  trigger: :api | :schedule | :parent | :rerun | nil,
  trigger_ref: String.t() | nil,
  updated_at: DateTime.t(),
  workflow_module: String.t(),
  workflow_name: String.t()
}

Functions

changeset(execution, attrs)

Creates a changeset for inserting a new workflow execution.

closed_statuses()

@spec closed_statuses() :: [status()]

Statuses of a finished run.

compensated_changeset(execution, results)

Creates a changeset for marking workflow as compensated (all compensations succeeded).

compensating_changeset(execution)

Creates a changeset for marking workflow as compensating.

compensation_failed_changeset(execution, results, error)

Creates a changeset for marking workflow compensation as failed.

lock_changeset(execution, locked_by)

Creates a changeset for locking a workflow for execution.

open_statuses()

@spec open_statuses() :: [status()]

Statuses of a run that's still going: it always keeps its key.

reusable_statuses(policy)

@spec reusable_statuses(atom()) :: [status()]

The statuses a key's holder can be in for a new start to take the key under policy. Open holders never give it up.

reuse_policies()

@spec reuse_policies() :: [atom()]

The reuse: policies a workflow can declare.

status_changeset(execution, status, attrs \\ %{})

Creates a changeset for updating workflow status.