Grouper.Data (Grouper v0.1.0) View Source

uniform data layer for groups of processes

Link to this section Summary

Functions

identifies which type of group is being used, builds API functions, and caches them in the process dictionary

delete data value of a given type and a given key

enumerates all key-values of a given data type

get data value of a given type and a given key

store data value of a given type and a given key

Link to this section Types

Specs

key() :: any()

Specs

opts() :: keyword()

Specs

t() :: %Grouper.Data{
  del: (type(), key() -> value() | nil),
  enum: (type() -> [{{type(), key()}, value()}] | [{key(), value()}]),
  get: (type(), key() -> value() | nil),
  group_leader: atom() | pid(),
  put: (type(), key(), value() -> value() | nil)
}

Specs

type() :: atom()

Specs

value() :: any()

Link to this section Functions

Specs

api(opts()) :: {:ok, t()} | {:error, :no_group}

identifies which type of group is being used, builds API functions, and caches them in the process dictionary

Options

  • :leader - override detected group leader with specified one (mostly used in testing)
Link to this function

del(type, key, opts \\ [])

View Source

Specs

del(type(), key(), opts()) :: {:ok, value() | nil} | {:error, :no_group}

delete data value of a given type and a given key

Specs

enum(type(), opts()) ::
  {:ok, [{{type(), key()}, value()}] | [{key(), value()}]} | {:error, :no_group}

enumerates all key-values of a given data type

Specify the special type :_ to read data of all types

Link to this function

get(type, key, opts \\ [])

View Source

Specs

get(type(), key(), opts()) :: {:ok, value() | nil} | {:error, :no_group}

get data value of a given type and a given key

Link to this function

put(type, key, val, opts \\ [])

View Source

Specs

put(type(), key(), value(), opts()) ::
  {:ok, value() | nil} | {:error, :no_group}

store data value of a given type and a given key