Erlang configuration provider / application:get_env/2 on steroids
Erlang
64
69 commits
updated Sep 16, 2015
Confetti is configuration provider for your Erlang applications.
Basically it's application:get_env/2 on steroids.

process_a can not break process_b
application:start(confetti).
then
%% your process
%% (...)
init([]) ->
confetti:use(my_foo), %% reads configuration terms
%% from "conf/my_foo.conf",
%% spawns new configuration provider
%% if needed...
confetti:fetch(my_foo), %% fetches the configuration terms
{ok, #state{}}.
%% (...)
%% react to configuration changes
handle_info({config_reloaded, NewConf}, State) -> (...)
confetti:use(foo, [
%% Specify config file location
{location, {"conf/bar", "foo.cnf"},
%% Make sure it's more than just correct Erlang term
%% or even transform the terms into something!
%% Validator funs should accept Config and return {ok, NewConf}
%% on success, error otherwise.
{validators, [fun validate_foo_config/1]},
%% ignore notifications for current process
{subscribe, false}
]).
-module(my_commands).
export([foo/1, foo/3]).
foo(help) ->
"Foo does bar two times!".
foo(Param1, Param2, Param3) ->
%% perform command logic
"bar bar".
Let confetti know about it:
%% conf/mgmt_conf.conf
{port, 50000}.
{plugins, [my_commands]}.
Assuming your application is already running, perform live management configruation reload:
$ telnet localhost 50000
...
(nonode@nohost)> reload mgmt_conf
ok
$ figlet MyApp > priv/helo.txt
rebar compile; erl -pa ebin -boot start_sasl -s confetti_app1> example_srv:start_link().telnet localhost 50000help for available commands, and help COMMAND for command usage
details.BSD License.
See LICENSE file for details.
Adam Rutkowski <adam.rutkowski@jtendo.com>
Feel encouraged to spot bugs/poor code and implement new sexy features.
Also, make sure, you add yourself to the authors where appropriate!
Thanks.
Erlang
100.0%
Erlang configuration provider / application:get_env/2 on steroids
Erlang
64
69 commits
updated Sep 16, 2015
Confetti is configuration provider for your Erlang applications.
Basically it's application:get_env/2 on steroids.

process_a can not break process_b
application:start(confetti).
then
%% your process
%% (...)
init([]) ->
confetti:use(my_foo), %% reads configuration terms
%% from "conf/my_foo.conf",
%% spawns new configuration provider
%% if needed...
confetti:fetch(my_foo), %% fetches the configuration terms
{ok, #state{}}.
%% (...)
%% react to configuration changes
handle_info({config_reloaded, NewConf}, State) -> (...)
confetti:use(foo, [
%% Specify config file location
{location, {"conf/bar", "foo.cnf"},
%% Make sure it's more than just correct Erlang term
%% or even transform the terms into something!
%% Validator funs should accept Config and return {ok, NewConf}
%% on success, error otherwise.
{validators, [fun validate_foo_config/1]},
%% ignore notifications for current process
{subscribe, false}
]).
-module(my_commands).
export([foo/1, foo/3]).
foo(help) ->
"Foo does bar two times!".
foo(Param1, Param2, Param3) ->
%% perform command logic
"bar bar".
Let confetti know about it:
%% conf/mgmt_conf.conf
{port, 50000}.
{plugins, [my_commands]}.
Assuming your application is already running, perform live management configruation reload:
$ telnet localhost 50000
...
(nonode@nohost)> reload mgmt_conf
ok
$ figlet MyApp > priv/helo.txt
rebar compile; erl -pa ebin -boot start_sasl -s confetti_app1> example_srv:start_link().telnet localhost 50000help for available commands, and help COMMAND for command usage
details.BSD License.
See LICENSE file for details.
Adam Rutkowski <adam.rutkowski@jtendo.com>
Feel encouraged to spot bugs/poor code and implement new sexy features.
Also, make sure, you add yourself to the authors where appropriate!
Thanks.
Erlang
100.0%