HotConfig.Resolver behaviour (hot_config v0.2.0)

A behaviour with instructions how to reload configuration.

Link to this section Summary

Callbacks

Patch source of variables with content from the config provider.

A schema with instructions which apps and keys should be patched

Link to this section Callbacks

Link to this callback

merge_to_source(new_config)

Specs

merge_to_source(new_config :: map()) :: :ok

Patch source of variables with content from the config provider.

Example

def merge_to_source(new_config) do
  System.put_env(new_config)
end

# or if you're using `confispex`
def merge_to_source(new_config) do
  {:ok, _} = Application.ensure_all_started(:confispex)
  Confispex.merge_store(new_config)
end
Link to this callback

patching_schema()

Specs

patching_schema() :: [
  {app_name :: atom(),
   [key :: atom() | {key :: atom(), [{:after_patch, (() -> any())}]}]}
]

A schema with instructions which apps and keys should be patched

Example

def patching_schema do
  [
    third_party_app: [ThirdPartyApp.API],
    myapp: [
      MyApp.ScreenSharing,
      {MyApp.Repo, [after_patch: &MyApp2.Repo.stop/0]}
    ]
  ]
end