GithubHelp home page GithubHelp logo

paulperegud / confetti Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jtendo/confetti

0.0 3.0 0.0 145 KB

Erlang configuration provider / application:get_env/2 on steroids

License: BSD 2-Clause "Simplified" License

Erlang 100.00%

confetti's Introduction

Confetti

Confetti is configuration provider for your Erlang applications.

Basically it's application:get_env/2 on steroids.

Features

  1. Management console (accessible via telnet) - maintenance department will love you for this:

    • Configuration reload in runtime (designated processes receive notifications on reload)

    • Easily extensible with your own management commands (plugins!)

    • (TODO) broadcast working configuration across the Erlang cluster

       ![Confetti management console](http://mtod.org/assets/c3/w92p4radk4wg8.png)
      
  2. Configuration supervision:

    • Increase your system's uptime - previous working configuration is DETS-cached in case someone messes up the configuration files

    • Broken config for process_a can not break process_b

      Confetti supervision tree

  3. Easy to use

    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) -> (...)
  4. Customizable

    • Write configuration validators and more:

      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}
      ]).
    • Expose any module via the management console:

      -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
      
    • Provide your own welcome screen to the management console, i.e.:

      $ figlet MyApp > priv/helo.txt
      

Try it out quickly

  1. Obtain the source code
  2. rebar compile; erl -pa ebin -boot start_sasl -s confetti_app
  3. 1> example_srv:start_link().
  4. telnet localhost 50000
  5. Type help for available commands, and help COMMAND for command usage details.

License

BSD License. See LICENSE file for details.

Authors

Adam Rutkowski <[email protected]>

Contribute!

Feel encouraged to spot bugs/poor code and implement new sexy features.

Also, make sure, you add yourself to the authors where appropriate! Thanks.

confetti's People

Contributors

aerosol avatar paulperegud avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.