Anvil.Storage behaviour (Anvil v0.1.1)

View Source

Behaviour for storage backends.

Allows pluggable storage implementations (ETS, Postgres, etc.)

Summary

Callbacks

get_assignment(state, id)

@callback get_assignment(state :: any(), id :: String.t()) ::
  {:ok, Anvil.Assignment.t(), state :: any()} | {:error, term()}

get_label(state, id)

@callback get_label(state :: any(), id :: String.t()) ::
  {:ok, Anvil.Label.t(), state :: any()} | {:error, term()}

get_sample(state, id)

@callback get_sample(state :: any(), id :: String.t()) ::
  {:ok, map(), state :: any()} | {:error, term()}

init(opts)

@callback init(opts :: keyword()) :: {:ok, state :: any()} | {:error, term()}

list_assignments(state, filters)

@callback list_assignments(state :: any(), filters :: keyword()) ::
  {:ok, [Anvil.Assignment.t()], state :: any()}

list_labels(state, filters)

@callback list_labels(state :: any(), filters :: keyword()) ::
  {:ok, [Anvil.Label.t()], state :: any()}

list_samples(state, filters)

@callback list_samples(state :: any(), filters :: keyword()) ::
  {:ok, [map()], state :: any()}

put_assignment(state, assignment)

@callback put_assignment(state :: any(), assignment :: Anvil.Assignment.t()) ::
  {:ok, state :: any()} | {:error, term()}

put_label(state, label)

@callback put_label(state :: any(), label :: Anvil.Label.t()) ::
  {:ok, state :: any()} | {:error, term()}

put_sample(state, sample)

@callback put_sample(state :: any(), sample :: map()) ::
  {:ok, state :: any()} | {:error, term()}