Kungfuig v0.1.1 Kungfuig behaviour 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

Link to this type

callback()

View Source
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.)

Link to this type

config()

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

The config map to be updated and exposed through callback

Link to this type

option()

View Source
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

Link to this type

t()

View Source
t() :: %Kungfuig{__meta__: [option()], 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

Link to this function

config(which \\ nil)

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

Link to this section Callbacks

Link to this callback

start_link(opts)

View Source
start_link(opts :: [option()]) :: GenServer.on_start()
Link to this callback

update_config(state)

View Source
update_config(state :: t()) :: config()

The actual implementation to update the config