Current section
Files
Jump to
Current section
Files
doc/readme.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.21.1">
<meta name="project" content="Consul Config Provider v0.1.0">
<title>ConsulConfigProvider ā Consul Config Provider v0.1.0</title>
<link rel="stylesheet" href="dist/html-9914b37a220eb2c313b6.css" />
<link rel="canonical" href="https://hexdocs.pm/consul_config_provider/readme.html" />
<script src="dist/sidebar_items-0117df032b.js"></script>
<script src="docs_config.js"></script>
<script async src="dist/html-9914b37a220eb2c313b6.js"></script>
</head>
<body data-type="extras">
<script>try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }</script>
<div class="main">
<button class="sidebar-button sidebar-toggle">
<span class="icon-menu" title="Collapse/expand sidebar"></span>
</button>
<section class="sidebar">
<form class="sidebar-search" action="search.html">
<button type="submit" class="search-button">
<span class="icon-search" aria-hidden="true"></span>
</button>
<button type="button" tabindex="-1" class="search-close-button">
<span class="icon-cross" title="Cancel search"></span>
</button>
<label class="search-label">
<input name="q" type="text" id="search-list" class="search-input" placeholder="Search..." aria-label="Search" autocomplete="off" />
</label>
</form>
<div class="autocomplete">
<div class="autocomplete-results">
</div>
</div>
<div class="sidebar-header">
<div class="sidebar-projectDetails">
<a href="https://github.com/blueshift-labs/consul_config_provider" class="sidebar-projectName">
Consul Config Provider </a>
<h2 class="sidebar-projectVersion">
v0.1.0
</h2>
</div>
</div>
<ul class="sidebar-listNav">
<li><a id="extras-list" href="#full-list">Pages</a></li>
<li><a id="modules-list" href="#full-list">Modules</a></li>
</ul>
<div class="gradient"></div>
<ul id="full-list" class="sidebar-fullList"></ul>
</section>
<section class="content">
<div class="content-outer">
<div id="content" class="content-inner">
<h1>ConsulConfigProvider</h1>
<h2 id="installation" class="section-heading">
<a href="#installation" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Installation
</h2>
<p>If <a href="https://hex.pm/docs/publish">available in Hex</a>, the package can be installed
by adding <code class="inline">consul_config_provider</code> to your list of dependencies in <code class="inline">mix.exs</code>:</p>
<pre><code class="nohighlight makeup elixir"><span class="kd">def</span><span class="w"> </span><span class="nf">deps</span><span class="w"> </span><span class="k" data-group-id="1910774686-1">do</span><span class="w">
</span><span class="p" data-group-id="1910774686-2">[</span><span class="w">
</span><span class="p" data-group-id="1910774686-3">{</span><span class="ss">:consul_config_provider</span><span class="p">,</span><span class="w"> </span><span class="s">"~> 0.1.0"</span><span class="p" data-group-id="1910774686-3">}</span><span class="w">
</span><span class="p" data-group-id="1910774686-2">]</span><span class="w">
</span><span class="k" data-group-id="1910774686-1">end</span></code></pre>
<p>Documentation can be generated with <a href="https://github.com/elixir-lang/ex_doc">ExDoc</a>
and published on <a href="https://hexdocs.pm">HexDocs</a>. Once published, the docs can
be found at <a href="https://hexdocs.pm/consul_config_provider">https://hexdocs.pm/consul_config_provider</a>.</p>
<h3 id="sample-usage" class="section-heading">
<a href="#sample-usage" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Sample Usage
</h3>
<ul>
<li>In mix.exs
</li>
</ul>
<pre><code class="nohighlight makeup elixir"><span class="ss">releases</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="9207931029-1">[</span><span class="w">
</span><span class="ss">release_name</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="9207931029-2">[</span><span class="w">
</span><span class="ss">include_executables_for</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="9207931029-3">[</span><span class="ss">:unix</span><span class="p" data-group-id="9207931029-3">]</span><span class="p">,</span><span class="w">
</span><span class="ss">applications</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="9207931029-4">[</span><span class="w">
</span><span class="ss">runtime_tools</span><span class="p">:</span><span class="w"> </span><span class="ss">:permanent</span><span class="p">,</span><span class="w">
</span><span class="ss">app_name_here</span><span class="p">:</span><span class="w"> </span><span class="ss">:permanent</span><span class="w">
</span><span class="p" data-group-id="9207931029-4">]</span><span class="p">,</span><span class="w">
</span><span class="ss">config_providers</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="9207931029-5">[</span><span class="w">
</span><span class="p" data-group-id="9207931029-6">{</span><span class="nc">ConsulConfigProvider</span><span class="p">,</span><span class="w">
</span><span class="p" data-group-id="9207931029-7">%{</span><span class="ss">prefix</span><span class="p">:</span><span class="w"> </span><span class="s">"services/app_namespace_in_consul/v1"</span><span class="p">,</span><span class="w"> </span><span class="ss">app_name</span><span class="p">:</span><span class="w"> </span><span class="ss">:app_name_here</span><span class="p" data-group-id="9207931029-7">}</span><span class="p" data-group-id="9207931029-6">}</span><span class="w">
</span><span class="p" data-group-id="9207931029-5">]</span><span class="w">
</span><span class="p" data-group-id="9207931029-2">]</span><span class="w">
</span><span class="p" data-group-id="9207931029-1">]</span><span class="p">,</span></code></pre>
<h3 id="information" class="section-heading">
<a href="#information" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Information
</h3>
<ul>
<li>This provider assumes the config name has a file extension which is either <code class="inline">.json</code>, <code class="inline">.yml</code>, or <code class="inline">.yaml</code> no other extensions are supported although PRs would be welcomed. If you do not follow this naming convention the provider will not work and throw.
</li>
<li>In the above the <code class="inline">prefix</code> is used for the keys path and can also be set with <code class="inline">CONSUL_PREFIX</code> (provide an empty string to the prefix if you wish to just use the env var)
</li>
<li>The <code class="inline">CONSUL_HOST</code> env var is used for the host to talk to consul and defaults to localhost
</li>
<li>The <code class="inline">CONSUL_PORT</code> env var is used for the port to talk to consul and defaults to 8500
</li>
<li>The http_module is dynamic and you can specify your own if you choose to do so. Just implement the HTTP behaviour and make your implementation return an <code class="inline">{:ok, json_body_binary_string}</code> as per the mojito example which will be the fallback. You might have to deal with coercing the input keyword list for the mojito arguments to support the client you are using, as well. You also need to set <code class="inline">config :consul_config_provider, :http_module, Client.YourClient</code> pointing to your client in your configs.
</li>
<li>Dependency-related configs are namespaced with their own application name while other configs use the input app_name for their namespace
</li>
</ul>
<footer class="footer">
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" target="_blank" rel="help noopener">ExDoc</a> (v0.21.1),
</span>
<span class="line">
designed by
<a href="https://twitter.com/dignifiedquire" target="_blank" rel="noopener" title="@dignifiedquire">Friedel Ziegelmayer</a>.
</span>
</p>
<p>
<button class="line footer-button night-mode-toggle">
Toggle night mode
</button>
<button class="line footer-button tooltips-toggle">
<span class="tooltips-option-disable">Disable tooltips</span>
<span class="tooltips-option-enable">Enable tooltips</span>
</button>
<button class="line footer-button display-shortcuts-help">
Display keyboard shortcuts
</button>
<button class="line footer-button display-quick-switch">
Go to a HexDocs package
</button>
</p>
</footer>
</div>
</div>
</section>
</div>
</body>
</html>