bean is a Rebar3 plugin that automatically generates a supervision tree based on dependencies between processes. With this plugin, you can automatically generate a supervision tree that satisfies the following requirements simply by running this:
- The number of processes restarted at one time is minimal.
- All processes that depend on the terminated process are restarted.
Dependencies between processes are defined as the directions of communication between processes. For example, if process
Add this plugin to your rebar.config
:
{plugins, [
{bean, {git, "https://github.com/ajfAfg/bean.git", {tag, "0.1.0"}}}
]}.
Then just call the plugin directly in an existing application:
$ rebar3 bean
===> Fetching bean
===> Compiling bean
<Plugin Output>
See the demo project for a complete example of this plugin.
- The supervision tree supervise the processes defined under the floor of
src
directory. - The supervisor source codes are output to
src/bean
directory. - The name of the root in the supervision tree is
bean
. - Supported restart strategies are
one_for_one
,one_for_all
, andrest_for_one
only.- i.e.
simple_one_for_one
is not supported.
- i.e.
Currently, bean has the following limitations:
- Only supports gen_server processes.
- Only
gen_server:call/2,3
andgen_server:cast/2
communications are supported. - Extractable communications are only those at the top level of the scope of each callback function of the module that implements gen_server.
- It is also assumed that the first argument of each communication function is a literal representing the name of the gen_server.
The supervision tree generation algorithm implemented in this plugin is proven to output a certain optimal tree. In addition, experimental results show that the algorithm is fast enough for many realistic cases, although it takes the worst-case exponential time. See the master's thesis "Automatic Generation of an Optimal Supervision Tree in Erlang" for details.
TODO: Add the link to the thesis when it is published.