Kungfuig.Backend behaviour (Kungfuig v1.0.1)
View SourceThe scaffold for the backend watching the external config source.
Example
defmodule Kungfuig.Backends.EnvTransform do
@moduledoc false
use Kungfuig.Backend, report: :logger, imminent: true
@impl Kungfuig.Backend
def get(meta) do
{:ok,
meta
|> Keyword.get(:for, [:kungfuig])
|> Enum.reduce(%{}, &Map.put(&2, &1, Application.get_all_env(&1)))}
end
@impl Kungfuig.Backend
def transform(%{kungfuig: env}) do
{:ok, for({k, v} <- env, {_, value} <- v, do: {k, value})}
end
end
Summary
Callbacks
The implementation of the call to remote that retrieves the data
The implementation of the call to remote that retrieves the data under a key specified
The key this particular config would be stored under, defaults to module name
The implementation of error reporting
The transformer that converts the retrieved data to internal representation
Callbacks
@callback get([Kungfuig.option()]) :: {:ok, any()} | {:error, any()}
The implementation of the call to remote that retrieves the data
@callback get([Kungfuig.option()], atom()) :: {:ok, any()} | {:error, any()}
The implementation of the call to remote that retrieves the data under a key specified
@callback key() :: atom()
The key this particular config would be stored under, defaults to module name
@callback report(any()) :: :ok
The implementation of error reporting
The transformer that converts the retrieved data to internal representation