Spectre.Receipt.Sink behaviour (Spectre v0.3.2)

Copy Markdown View Source

Adapter boundary for portable boundary receipts.

:disabled, :observational, and :required are orchestration policies; adapters only implement idempotent append and lookup. Any exception during append is classified as ambiguous because the write may have committed.

Summary

Types

config()

@type config() :: module() | {module(), keyword()} | nil | false

normalized()

@type normalized() :: nil | {module(), keyword()}

Callbacks

append(t, keyword)

@callback append(
  Spectre.Receipt.Envelope.t(),
  keyword()
) :: {:ok, :appended | :idempotent} | {:error, :ambiguous | term()}

get_payload(t, keyword)

(optional)
@callback get_payload(
  String.t(),
  keyword()
) :: {:ok, Spectre.Receipt.Envelope.t()} | :not_found | {:error, term()}

lookup(t, keyword)

@callback lookup(
  String.t(),
  keyword()
) :: {:ok, Spectre.Receipt.Envelope.t()} | :not_found | {:error, term()}

put_payload(t, keyword)

(optional)
@callback put_payload(
  Spectre.Receipt.Envelope.t(),
  keyword()
) :: {:ok, String.t()} | {:error, term()}

Functions

append(arg1, envelope, opts)

@spec append(normalized(), Spectre.Receipt.Envelope.t(), keyword()) ::
  {:ok, :appended | :idempotent} | {:error, term()}

get_payload(arg1, ref, opts)

@spec get_payload(normalized(), String.t(), keyword()) ::
  {:ok, Spectre.Receipt.Envelope.t()} | :not_found | {:error, term()}

lookup(arg1, id, opts)

@spec lookup(normalized(), String.t(), keyword()) ::
  {:ok, Spectre.Receipt.Envelope.t()} | :not_found | {:error, term()}

normalize(value)

@spec normalize(config()) :: {:ok, normalized()} | {:error, term()}

payload_capable?(arg1)

@spec payload_capable?(normalized()) :: boolean()

payload_ref(envelope)

@spec payload_ref(Spectre.Receipt.Envelope.t()) :: String.t()

Returns the mandatory content-addressed reference for a receipt payload.

put_payload(sink, envelope, opts)

@spec put_payload(normalized(), Spectre.Receipt.Envelope.t(), keyword()) ::
  {:ok, String.t()} | {:error, term()}