View Source Kungfuig behaviour (Kungfuig v0.4.2)

The behaviour defining the dynamic config provider.

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

examples

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

Callbacks

The actual implementation to update the config

Functions

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

Link to this section 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.)

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

The config map to be updated and exposed through callback

@type 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

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

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

Link to this section Callbacks

@callback start_link(opts :: [option()]) :: GenServer.on_start()
@callback update_config(state :: t()) :: config()

The actual implementation to update the config

Link to this section Functions

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

Link to this function

config(which \\ :!, supervisor \\ Kungfuig.Supervisor)

View Source
@spec config(which :: atom() | [atom()], supervisor :: Supervisor.supervisor()) :: t()