AshWorkflow.Entities.Undo (AshWorkflow v0.6.0)

Copy Markdown View Source

Configures undo for a workflow.

Undo rewinds a record to the state it occupied before its most recent state change, and records that rewind as a new transition log row whose undoes_id points at the row it reverses. The log is never mutated: history stays append-only, and both readings of it remain derivable — what actually happened, and what stands after corrections.

undo do
  within {30, :minutes}
  same_actor? true
end

Undo is opt-in twice over. The undo block enables the feature, and each transition that may be rewound must be marked undoable?: true. A workflow with an undo block but no undoable transitions is rejected at compile time.

Requires a transition_log — there is nothing to rewind to without one.

Summary

Functions

Returns within as a count of seconds, or nil when no window is configured.

Types

t()

@type t() :: %AshWorkflow.Entities.Undo{
  __spark_metadata__: term(),
  policy: term() | nil,
  same_actor?: boolean(),
  within: {pos_integer(), AshWorkflow.Entities.Timeout.duration_unit()} | nil
}

Functions

attribute_schema()

window_seconds(undo)

@spec window_seconds(t()) :: pos_integer() | nil

Returns within as a count of seconds, or nil when no window is configured.