expelledboy / plugerl

Most simple plugin system using Erlang behaviours.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plugerl

Travis Hex.pm Hex.pm

Most simple plugin system using Erlang behaviours.

Usage

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).

About

Most simple plugin system using Erlang behaviours.

License:Apache License 2.0


Languages

Language:Erlang 73.1%Language:Makefile 26.9%