Skip to content

spylik/erlroute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Erlroute

Erlroute is the simple router designed for Flow Based Programming paradigm.

The main idea is to use erlroute:pub everywhere, where you may require the data now or in the future.

Actually, erlroute do simple job - it just route messages or execution flows. Simply write erlroute:pub in places which will require dinamic route and "destination" you can define later.

Destinations could be: * other local or remote processes; * functions (local and on remote nodes); * pool workers.

Why just do not use AMQP broker for this purpose?

  1. AMQP brokers are really great! With AMQP you able to implement very flexible and complex solutions. But sometimes, when you just need to route messages inside your erlang application use amqp-broker is like to shoot out of cannon into sparrows. When you do not need full AMQP features, erlroute is here.

  2. AMQP brokers designed for message passing and advanced message routine logic, meanwhile erlroute is a simple router designed for simple message passing and dynamic execution flows inside your Erlang applications.

When erlroute useful for you and when not so?

  • Erlroute useful if you are going to design dynamically environment where one group of listeners, in some cases may require data from producers and in some another cases not;

  • Erlroute useful when you want to implement dynamical execution pipelines (flows) within multiple processes or within the same;

  • Erlroute useful during development - you don’t need anymore to think in advance about you may require the data from this line of code somwhere in future or not.

  • Erlroute useful to avoid multi-send constructions like:

SomeData = {time, erlang:system_time()},
process1 ! SomeData,
process2 ! SomeData,
process3 ! SomeData,
process4 ! SomeData,
process5 ! SomeData,
process6 ! SomeData.

With erlroute you can write just:

erlroute:pub(<<"some_test_topic">>, {time, erlang:system_time()}).

And then, subscibers could easy to subscribe:

erlroute:sub(<<"some_test_topic">>).

You can also subscribe functions:

erlroute:sub(<<"some_test_topic">>, some_module_name, send_email, ["exampl@example.com"]).
erlroute:sub(<<"some_test_topic">>, fun(Topic, Msg) -> do_some_stuff end).
  • Erlroute not useful if you are going to produce data which may required by applications written in other languages. In this case the best way is to use AMQP-broker. Erlroute designed only for internal erlang routes.

Erlroute for erlang-driven evolutionary neural networks and genetic algorithms.

Erlroute originally was developed as a playground for genetic algorithms. Actually it does the same job as axons and dendrits. Some neuron generate and produce signals via axons and other neurons receiving signals via dendrites. In erlroute axon output is erlroute:pub and dendites could be linked to axons by erlroute:sub. With erlroute you able to implement genetic evolution as well - you can obtain full list of availiable producers which match your specific criterias and topics and randomly create new links with erlroute:sub and randomly destroy existing with erlroute:unsub during your software evolution.

Key feutures:

  • ets based;

  • due per module cache 'erlroute:pub' is very cheap;

  • support not only message passings, but functions and pools as destinations;

  • parse transform for build ets-names during compile time;

  • works both for local and distrubuted erlang modes;

  • cross-node auto-recovery of subscribtions after network splits in distributed mode;

  • auto-cleanups of subscribtions when the subscriber subscribed by it’s own pid dies.

  • todo: s̶u̶p̶p̶o̶r̶t̶ ̶R̶a̶b̶b̶i̶t̶M̶Q̶-̶s̶t̶y̶l̶e̶ ̶r̶o̶u̶t̶i̶n̶g̶_̶k̶e̶y̶s̶

Interface

Erlroute support some useful shortcuts for prevent unnecessary terms constructions during runtime. To use shourtcuts +{parse_transform, erlroute_transform} must be added as compile options (suggested way).

Also you can use macros eg. ?PUB(Message) from erlroute.hrl instead of parse_transform, for this you need to -include("erlroute.hrl"). in file from where you planning to call that macros (if you use parse transform you don’t need it).

About

Simple pub/sub Erlang message router

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published