ExStorageService.Metadata.Backend behaviour (ex_storage_service v0.6.3)

Copy Markdown View Source

Storage boundary used by atomic object metadata operations.

Reads include the Concord modification revision needed for compare-and-swap. Prefix scans intentionally expose values only; callers that need a revision must read the individual key with get/2.

Summary

Types

key()

@type key() :: binary()

page_entry()

@type page_entry() :: %{key: key(), value: term(), mod_revision: non_neg_integer()}

page_result()

@type page_result() :: %{entries: [page_entry()], next_cursor: key() | nil}

read_result()

@type read_result() :: %{value: term(), mod_revision: non_neg_integer()}

transaction_spec()

@type transaction_spec() :: %{compare: [term()], success: [term()], failure: [term()]}

Callbacks

delete(key, keyword)

@callback delete(
  key(),
  keyword()
) :: :ok | {:error, term()}

get(key, keyword)

@callback get(
  key(),
  keyword()
) :: {:ok, read_result() | nil} | {:error, term()}

get_all(keyword)

@callback get_all(keyword()) :: {:ok, [{key(), term()}]} | {:error, term()}

list_page(binary, arg2, pos_integer, keyword)

(optional)
@callback list_page(binary(), key() | nil, pos_integer(), keyword()) ::
  {:ok, page_result()} | {:error, term()}

prefix_scan(binary, keyword)

@callback prefix_scan(
  binary(),
  keyword()
) :: {:ok, [{key(), term()}]} | {:error, term()}

put(key, term, keyword)

@callback put(key(), term(), keyword()) :: :ok | {:error, term()}

resolve_operation(key, keyword)

@callback resolve_operation(
  key(),
  keyword()
) :: {:ok, read_result() | nil} | {:error, term()}

resolve_transaction(binary, keyword)

@callback resolve_transaction(
  binary(),
  keyword()
) :: {:ok, term()} | {:error, term()}

scan(binary, keyword)

@callback scan(
  binary(),
  keyword()
) :: {:ok, [{key(), term()}]} | {:error, term()}

transaction(transaction_spec, keyword)

@callback transaction(
  transaction_spec(),
  keyword()
) :: {:ok, term()} | {:error, term()}