Most simple plugin system using Erlang behaviours.
Module that uses plugins.
-callback install(Config :: map()) -> ok | {error, atom()}.
main() ->
Config = project:config(),
plugerl:over(my_behaviour, with_my_behaviours(Config)),
loop().
loop() ->
receive Msg -> io:format("~p~n", [Msg]) end,
loop().
with_my_behaviours(Config) ->
fun(Plugin) ->
Plugin:install(Config)
end.
Plugin module.
install(Config) ->
Timeout = maps:get(timeout, Config, 10),
timer:send_interval(Timeout, from_plugin).