[erlang-questions] config based rules grammar
Jesper Louis Andersen
Wed Feb 16 15:19:04 CET 2011
On Wed, Feb 16, 2011 at 13:35, Nav <orionqwest@REDACTED> wrote:
> I have been defining quite many rules in config file, so that my
> erlang program can read and interpret. These rules apply for every
> incoming message to gen_server, and looks somewhat like
You can simply embed Erlang code and load it for execution. The
fastest solution is probably to use the compiler module to read in and
compile the code sequences - then load that module onto the Erlang VM.
Now you can just call to the module to get a rule evaluation. Hot code
deployment means you can also cope with runtime configuration changes:
Recompile the module, load the new code and your gen_servers will
automatically begin to pick up the new code in question.
A less fast approach is to turn each of your rules into fun(..) -> ...
end blocks and then compile the rules into a single fun which then
gets called. It doesn't require the recompilation machinery, but it is
still faster than purely interpreting the rules, I'd wager.
More information about the erlang-questions