View Source Kungfuig behaviour (Kungfuig v1.0.0)
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.
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
The start_link/1
function wrapping the GenServer.start_link/3
Functions
The config that is manages by this behaviour is a simple map
Types
@type 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
.)
The config map to be updated and exposed through callback
@type option() :: {:name, GenServer.name()} | {: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
@type t() :: %Kungfuig{ __meta__: [option()], __start_options__: [], __previous__: config(), state: config() }
The start_link/1
function wrapping the GenServer.start_link/3
Callbacks
@callback start_link(opts :: [option()]) :: GenServer.on_start()
The actual implementation to update the config
Functions
The config that is manages by this behaviour is a simple map
@spec config(which :: atom() | [atom()], supervisor :: Supervisor.supervisor()) :: t()