ConsulConfigProvider

License: MITHex pmhexdocs.pm

Installation

The package can be installed by adding consul_config_provider to your list of dependencies in mix.exs:

def deps do
  [
    {:consul_config_provider, "~> 0.1.4"},
    {:mojito, "~> 0.6.3"}, # default implmentation for http client
  ]
end

The docs can be found at https://hexdocs.pm/consul_config_provider.

Sample Usage

Transformer

defmodule Example.Config do
  @behaviour ConsulConfigProvider.Transformer

  @impl true
  def transform({:erlkaf, [clients: [producer: [client_options: client_options]]]}) do
    default_client_options =
      Application.get_env(:erlkaf, :clients, [])
      |> Keyword.get(:producer, [])
      |> Keyword.get(:client_options, [])

    {:erlkaf,
     [
       clients: [
         producer: [
           type: :producer,
           client_options: Keyword.merge(default_client_options, client_options)
         ]
       ]
     ]}
  end

  @impl true
  def transform(config), do: config
end

Then in your configs:

config :consul_config_provider, transformer_module: Example.Config

Information