ASM.Extensions.Persistence (ASM v0.9.2)

Copy Markdown View Source

Public persistence extension API.

This domain adds optional persistence paths and async integration hooks without coupling core runtime modules to extension internals.

Summary

Types

Known persistence store implementations shipped by this extension.

Store process reference implementing the ASM.Store callbacks.

Types

store_kind()

@type store_kind() :: :memory | :file

Known persistence store implementations shipped by this extension.

store_ref()

@type store_ref() :: pid()

Store process reference implementing the ASM.Store callbacks.

Functions

append_event(store, event)

@spec append_event(store_ref(), ASM.Event.t()) :: :ok | {:error, ASM.Error.t()}

flush_writer(writer, timeout \\ 5000)

@spec flush_writer(pid(), timeout()) :: :ok | {:error, ASM.Error.t()}

list_events(store, session_id)

@spec list_events(store_ref(), String.t()) ::
  {:ok, [ASM.Event.t()]} | {:error, ASM.Error.t()}

rebuild_run(store, session_id, run_id)

@spec rebuild_run(store_ref(), String.t(), String.t()) ::
  {:ok,
   %{state: ASM.Run.State.t(), result: ASM.Result.t(), events: [ASM.Event.t()]}}
  | {:error, ASM.Error.t()}

replay_session(store, session_id, initial_state, reducer)

@spec replay_session(store_ref(), String.t(), term(), (term(), ASM.Event.t() ->
                                                   term())) ::
  {:ok, term()} | {:error, ASM.Error.t()}

reset_session(store, session_id)

@spec reset_session(store_ref(), String.t()) :: :ok | {:error, ASM.Error.t()}

start_store(other, opts)

@spec start_store(
  store_kind(),
  keyword()
) :: GenServer.on_start() | {:error, ASM.Error.t()}

start_writer(opts)

@spec start_writer(keyword()) :: GenServer.on_start()

writer_plug(writer, opts \\ [])

@spec writer_plug(
  pid(),
  keyword()
) :: {module(), keyword()}