MedEx.Storage behaviour (med_ex v0.2.0)

Copy Markdown View Source

A single temporary writer owns its adapter state. A commit receipt names the synchronized journal generation and its exclusive sequence/sample boundaries. An unclassified IO error after appending begins is an unknown outcome.

Summary

Types

result()

@type result() ::
  {:ok, state(), map()} | {:error, {:not_committed | :outcome_unknown, term()}}

state()

@type state() :: term()

Callbacks

close(state)

@callback close(state()) :: term()

commit_batch(state, arg2)

@callback commit_batch(state(), {:frames, [MedEx.SampleFrame.t()]} | {:gap, map()}) ::
  result()

lookup(state, arg2, term)

@callback lookup(state(), :frame | :gap, term()) :: {:ok, binary()} | :missing

open(keyword)

@callback open(keyword()) :: result()

recover(t, keyword)

@callback recover(Path.t(), keyword()) :: {:ok, map()} | {:error, term()}

seal(state, arg2, arg3)

@callback seal(state(), :finished | :interrupted | :failed, binary() | %{conflict: map()}) ::
  {:ok, MedEx.StreamIndex.t()} | {:error, term()}

usage(state)

@callback usage(state()) :: %{
  raw_bytes: non_neg_integer(),
  frame_count: non_neg_integer(),
  span_count: non_neg_integer(),
  journal_bytes: non_neg_integer()
}