Giter VIP home page Giter VIP logo

rig's Introduction

rig

Auto-reloading Erlang config indexer

Build Status Coverage Status

API

rig:all(table()) ->
    {ok, [{key(), value()}]} | {error, unknown_table} .

rig:read(table(), key()) ->
    {ok, value()} | {error, unknown_key | unknown_table}.

rig:read(table(), key(), value()) ->
    {ok, value()} | {error, unknown_table}.

rig:version(table()) ->
    {ok, ets:tid()} | {error, unknown_table}.

The config files are length delimited using base 128 varints to encode length.

Environment

Name Type Default Description
config [config() | {basedir(), [config()]}] [] configs to be indexed
reload_delay non_neg_integer() 5000 time between state reloads in milliseconds

Example

[{rig, [
  {configs, [
    {applists, "./priv/proto/development/applists.proto", "my_proto:decoder/1.", []},
    {clients, "./priv/bert2/development/clients.bert2", term, []},

    {"./priv/bert2/production/", [
      {ads, "ads.bert2", term, []},
      {sites, "sites.bert2", term, []}
    ]},

    {"./priv/proto/production/", [
      {applists, "applists.proto", "my_proto:decoder/1.", []},
      {sitelists, "sitelists.proto", "my_proto:decoder/1.", []}
    ]},
  ]},
  {reload_delay, 500}
}].

Types

-type config()         :: {table_name(), file:filename(), decoder(), config_options()}.
-type config_option()  :: {element_index, pos_integer()} | {subscribers, [pid()]}.
-type config_options() :: [config_option()].
-type decoder()        :: fun((binary()) -> tuple()) | term.
-type table_name()     :: atom().

Tests

make dialyzer
make elvis
make eunit
make xref

License

The MIT License (MIT)

Copyright (c) 2016-2017 Louis-Philippe Gauthier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

rig's People

Contributors

fbernier avatar lpgauth avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rig's Issues

Race condition in test suite?

When running the tests immediately after building for the first time:

Running elvis rock...
Loading files...
Loading src/rig.erl
Loading src/rig_app.erl
Loading src/rig_index.erl
Loading src/rig_server.erl
Loading src/rig_sup.erl
Loading src/rig_utils.erl
Loading test/rig_tests.erl
Loading test/test_config.erl
Applying rules...
# src/rig.erl [OK]
# src/rig_app.erl [OK]
# src/rig_index.erl [OK]
# src/rig_server.erl [OK]
# src/rig_sup.erl [OK]
# src/rig_utils.erl [OK]
# test/rig_tests.erl [OK]
# test/test_config.erl [OK]
Loading files...
Loading elvis.config
Applying rules...
# elvis.config [OK]
Running rebar3 xref...
===> Verifying dependencies...
===> Compiling rig                                                                                                       
===> Running cross reference analysis...                                                                                 
Running rebar3 eunit...
===> Fetching coveralls ({git,"https://github.com/markusn/coveralls-erl",
                                     {branch,"master"}})                                                                 
===> Compiling coveralls                                                                                                 
===> Verifying dependencies...                                                                                           
===> Linking _build/default/lib/metal to _build/test/lib/metal                                                           
===> Compiling rig                                                                                                       
===> Performing EUnit tests...                                                                                           
======================== EUnit ========================
file "rig.app"
  application 'rig'
    module 'rig'
      rig_tests: rig_test (module 'rig_tests')...*failed*
in function rig_tests:rig_test/0 (/home/richard.kallos/work/rig/_build/test/lib/rig/test/rig_tests.erl, line 39)
in call from eunit_test:'-mf_wrapper/2-fun-0-'/2 (eunit_test.erl, line 273)
in call from eunit_test:run_testfun/1 (eunit_test.erl, line 71)
in call from eunit_proc:run_test/1 (eunit_proc.erl, line 510)
in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 335)
in call from eunit_proc:handle_test/2 (eunit_proc.erl, line 493)
in call from eunit_proc:tests_inorder/3 (eunit_proc.erl, line 435)
in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 325)
**error:{badmatch,{error,unknown_table}}
  output:<<"">>

      [done in 0.511 s]
    module 'rig_app'
    module 'rig_index'
    module 'rig_server'
    module 'rig_sup'
    module 'rig_utils'
    [done in 0.538 s]
  [done in 0.549 s]
module 'test_config'
=======================================================
  Failed: 1.  Skipped: 0.  Passed: 0.
===> Error running tests
make: *** [Makefile:32: eunit] Error 1

Reproducible by removing test/files/*.bert
I think that calling encode_bert_configs() before rig_app:start() might fix things.

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.