Kungfuig behaviour (Kungfuig v0.3.0) View Source

The behaviour defining the dynamic config provider.

Kungfuig provides a plugagble drop-in support for live configurations.

Examples

Kungfuig.Supervisor.start_link()
Kungfuig.config()
#⇒ %{env: %{kungfuig: []}, system: %{}}

Kungfuig.config(:env)
#⇒ %{kungfuig: []}

Application.put_env(:kungfuig, :foo, 42)
Kungfuig.config(:env)
#⇒ %{kungfuig: [foo: 42]}

The configuration is frequently updated.

Link to this section Summary

Types

The callback to be used for subscibing to config updates.

The config map to be updated and exposed through callback

The option that can be passed to start_link/1 function

t()

The start_link/1 function wrapping the GenServer.start_link/3

Functions

The config that is manages by this behaviour is a simple map

Callbacks

The actual implementation to update the config

Link to this section Types

Specs

callback() ::
  {module(), atom()}
  | (config() -> :ok)
  | {GenServer.name() | pid(), {:call | :cast | :info, atom()}}

The callback to be used for subscibing to config updates.

Might be an anonymous function, an {m, f} tuple accepting a single argument, or a process identifier accepting call, cast or simple message (:info.)

Specs

config() :: %{required(atom()) => term()}

The config map to be updated and exposed through callback

Specs

option() ::
  {:callback, callback()}
  | {:interval, non_neg_integer()}
  | {:anonymous, boolean()}
  | {:start_options, [GenServer.option()]}
  | {atom(), term()}

The option that can be passed to start_link/1 function

Specs

t() :: %Kungfuig{__meta__: [option()], __previous__: config(), state: config()}

The start_link/1 function wrapping the GenServer.start_link/3

Link to this section Functions

The config that is manages by this behaviour is a simple map

Specs

config(which :: atom() | [atom()] | nil) :: t()

Link to this section Callbacks

Specs

start_link(opts :: [option()]) :: GenServer.on_start()

Specs

update_config(state :: t()) :: config()

The actual implementation to update the config