Bandera.Store behaviour (bandera v0.1.0)

Copy Markdown

Behaviour for the active store the public API talks to.

The concrete store is selected at RUNTIME via Bandera.Config (default Bandera.Store.TwoLevel). lookup/1 may add caching; writes go to the persistent layer.

Summary

Callbacks

Returns {:ok, names} with every stored flag name, or {:error, reason}.

Returns {:ok, flags} with every stored flag, or {:error, reason}.

Removes the entire flag and returns the resulting (empty) flag (or {:error, reason}).

Removes a single gate from the flag and returns the updated flag (or {:error, reason}).

Reads a flag by name (may serve from cache). Returns {:ok, flag} or {:error, reason}.

Writes gate onto the flag and returns the updated flag (or {:error, reason}).

Functions

The runtime-selected active store module.

Callbacks

all_flag_names()

@callback all_flag_names() :: {:ok, [atom()]} | {:error, term()}

Returns {:ok, names} with every stored flag name, or {:error, reason}.

all_flags()

@callback all_flags() :: {:ok, [Bandera.Flag.t()]} | {:error, term()}

Returns {:ok, flags} with every stored flag, or {:error, reason}.

delete(flag_name)

@callback delete(flag_name :: atom()) :: {:ok, Bandera.Flag.t()} | {:error, term()}

Removes the entire flag and returns the resulting (empty) flag (or {:error, reason}).

delete(flag_name, gate)

@callback delete(flag_name :: atom(), gate :: Bandera.Gate.t()) ::
  {:ok, Bandera.Flag.t()} | {:error, term()}

Removes a single gate from the flag and returns the updated flag (or {:error, reason}).

lookup(flag_name)

@callback lookup(flag_name :: atom()) :: {:ok, Bandera.Flag.t()} | {:error, term()}

Reads a flag by name (may serve from cache). Returns {:ok, flag} or {:error, reason}.

put(flag_name, gate)

@callback put(flag_name :: atom(), gate :: Bandera.Gate.t()) ::
  {:ok, Bandera.Flag.t()} | {:error, term()}

Writes gate onto the flag and returns the updated flag (or {:error, reason}).

Functions

active()

@spec active() :: module()

The runtime-selected active store module.