Chronicle.Provider behaviour (chronicle v0.1.0)

Copy Markdown

Behaviour implemented by audit storage providers.

write_group/3 must make the group and its events visible atomically whenever the underlying store supports transactions.

A behaviour rather than a bare module because there are genuinely two implementations with different guarantees: the Ecto provider, which is transactional and signs everything, and the in-memory one, which exists for tests. Only the first is a place to keep an audit trail — the memory provider has no chain, no persistence, and nothing to verify.

Summary

Types

options()

@type options() :: keyword()

result()

@type result() :: :ok | {:ok, term()} | {:error, term()}

Callbacks

write_event(t, options)

@callback write_event(Chronicle.Event.t(), options()) :: result()

write_group(t, list, options)

@callback write_group(Chronicle.Group.t(), [Chronicle.Event.t()], options()) :: result()

Functions

resolve(opts)

@spec resolve(keyword()) :: {:ok, module(), keyword()} | {:error, term()}

write_event(event, opts \\ [])

@spec write_event(
  Chronicle.Event.t(),
  keyword()
) :: result()

write_group(group, events, opts \\ [])

@spec write_group(Chronicle.Group.t(), [Chronicle.Event.t()], keyword()) :: result()