Spectre.Awaitable (Spectre v0.3.0)

Copy Markdown View Source

Runtime state waiting for user input.

Awaitables are deliberately small. They identify what kind of input is needed and, when applicable, which effect they are gating.

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

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(),
  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.

reject(awaitable, label)

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

Marks an awaitable as rejected with the matched policy label.