Snodo.Extensions.Tasks.Transition (snodo_tasks v0.2.0)

Copy Markdown View Source

Pure application of a validated Task event to a revisioned snapshot.

The reducer emits :applied only when durable state changes and advances the revision exactly once. :unchanged represents a valid no-op. Stores may use :duplicate when replaying a previously committed event; pure application does not emit that outcome because event history belongs to the store.

Summary

Functions

Applies one event at the store-assigned commit timestamp.

Types

outcome()

@type outcome() :: :applied | :unchanged | :duplicate

t()

@type t() :: %Snodo.Extensions.Tasks.Transition{
  committed_at: String.t(),
  effects: map(),
  event_revision: non_neg_integer(),
  outcome: outcome(),
  snapshot: Snodo.Extensions.Tasks.Snapshot.t()
}

Functions

apply(snapshot, event, committed_at)

@spec apply(
  Snodo.Extensions.Tasks.Snapshot.t(),
  Snodo.Extensions.Tasks.Event.t(),
  String.t()
) ::
  {:ok, t()} | {:error, term()}

Applies one event at the store-assigned commit timestamp.