Jidoka.Effect.Journal (Jidoka v0.9.0)

Copy Markdown View Source

Intent/result journal used to make effects replayable.

Summary

Functions

Returns true when an intent is recorded without a result.

Returns a recorded intent by intent value or identifier.

Returns true when the journal contains the intent.

Builds an empty or restored effect journal.

Builds an effect journal and raises if the attributes are invalid.

Records an intent by its stable identifier.

Records an effect result by its intent identifier.

Returns the recorded result for an intent, if it exists.

Returns the Zoi schema for an effect journal.

Types

t()

@type t() :: %Jidoka.Effect.Journal{
  intents: %{optional(binary()) => term()},
  results: %{optional(binary()) => term()}
}

Functions

incomplete_intent?(journal, intent)

@spec incomplete_intent?(t(), Jidoka.Effect.Intent.t()) :: boolean()

Returns true when an intent is recorded without a result.

intent_for(journal, id)

@spec intent_for(t(), Jidoka.Effect.Intent.t() | String.t()) ::
  Jidoka.Effect.Intent.t() | nil

Returns a recorded intent by intent value or identifier.

intent_recorded?(journal, intent_or_id)

@spec intent_recorded?(t(), Jidoka.Effect.Intent.t() | String.t()) :: boolean()

Returns true when the journal contains the intent.

new(attrs \\ [])

@spec new(keyword() | map()) :: {:ok, t()} | {:error, term()}

Builds an empty or restored effect journal.

new!(attrs \\ [])

@spec new!(keyword() | map()) :: t()

Builds an effect journal and raises if the attributes are invalid.

put_intent(journal, intent)

@spec put_intent(t(), Jidoka.Effect.Intent.t()) :: t()

Records an intent by its stable identifier.

put_result(journal, result)

@spec put_result(t(), Jidoka.Effect.Result.t()) :: t()

Records an effect result by its intent identifier.

result_for(journal, intent)

@spec result_for(t(), Jidoka.Effect.Intent.t()) :: Jidoka.Effect.Result.t() | nil

Returns the recorded result for an intent, if it exists.

schema()

@spec schema() :: Zoi.schema()

Returns the Zoi schema for an effect journal.