AshOnetime.ExternalEffect behaviour (ash_onetime v0.5.0)

Copy Markdown View Source

Contract for a peer effect that is idempotent and recoverable by operation key.

The first argument to both callbacks is the authoritative committed claim UUID. An adapter must pass it unchanged to the peer's idempotency and recovery surfaces. :absent is authoritative proof that no peer operation exists; every uncertain, exceptional, or malformed outcome is ambiguity and must not permit a new key.

Summary

Types

operation_key()

@type operation_key() :: Ecto.UUID.t()

peer_result()

@type peer_result() :: term()

subject()

@type subject() :: Ash.Changeset.t() | Ash.ActionInput.t()

trusted_context()

@type trusted_context() :: map()

Callbacks

execute(operation_key, subject, trusted_context)

@callback execute(operation_key(), subject(), trusted_context()) ::
  {:ok, peer_result()} | {:error, :outcome_unknown}

recover(operation_key, subject, trusted_context)

@callback recover(operation_key(), subject(), trusted_context()) ::
  {:ok, peer_result()} | :absent | :unknown

Functions

operation_key(arg1)

@spec operation_key(subject()) :: {:ok, operation_key()} | :error

result(arg1)

@spec result(subject()) :: {:ok, peer_result()} | :error