Spectre.Awaitable (Spectre v0.3.4)

Copy Markdown View Source

Runtime state waiting for a policy resolution.

Awaitables are deliberately small. They identify what kind of input is needed, who may resolve it, and, when applicable, which effect they gate.

Summary

Functions

Marks an awaitable as accepted with the matched policy label.

Marks an awaitable as cancelled.

Marks an awaitable as expired.

Increments the retry attempt counter.

Opens a policy awaitable for an effect.

Marks an awaitable as rejected with the matched policy label.

Types

resolver()

@type resolver() :: :conversation | :external

status()

@type status() :: :open | :accepted | :rejected | :cancelled | :expired

t()

@type t() :: %Spectre.Awaitable{
  attempts: non_neg_integer(),
  id: term(),
  kind: atom(),
  label: atom() | nil,
  max_attempts: pos_integer() | nil,
  metadata: map(),
  name: term(),
  resolver: resolver(),
  run_id: String.t() | nil,
  status: status(),
  subject_id: term()
}

Functions

accept(awaitable, label)

@spec accept(t(), atom()) :: t()

Marks an awaitable as accepted with the matched policy label.

cancel(awaitable)

@spec cancel(t()) :: t()

Marks an awaitable as cancelled.

expire(awaitable)

@spec expire(t()) :: t()

Marks an awaitable as expired.

increment(awaitable)

@spec increment(t()) :: t()

Increments the retry attempt counter.

open_policy(policy, subject, opts \\ [])

@spec open_policy(term(), Spectre.Effect.t() | term(), keyword()) :: t()

Opens a policy awaitable for an effect.

:conversation is the compatibility default. :external keeps subsequent conversation turns on normal routing and requires a host-sourced decision.

reject(awaitable, label)

@spec reject(t(), atom()) :: t()

Marks an awaitable as rejected with the matched policy label.