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.2"},
    {:finch, "~> 0.12"}, # default implementation for http client
  ]
end

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

Sample Usage

releases: [
  release_name: [
    include_executables_for: [:unix],
    applications: [
      runtime_tools: :permanent,
      app_name_here: :permanent
    ],
    config_providers: [
      {ConsulConfigProvider,
       %{prefix: "services/app_namespace_in_consul/v1", app_name: :app_name_here}}
    ]
  ]
],

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

Release