Add src/hk_event_sup.erl
Browse files- src/hk_event_sup.erl +30 -0
src/hk_event_sup.erl
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%%%-------------------------------------------------------------------
|
| 2 |
+
%%% @doc Supervises the event/observability plane: the event bus
|
| 3 |
+
%%% itself. A crash here means the system loses its "nervous
|
| 4 |
+
%%% system" (the frontend goes dark) but subsystems keep running --
|
| 5 |
+
%%% `hk_event_bus:publish/1' calls simply fail until the bus is back,
|
| 6 |
+
%%% which is why publish sites should not treat publish failure as a
|
| 7 |
+
%%% reason to abort the underlying operation (visibility failing is
|
| 8 |
+
%%% never allowed to silently become "the operation didn't happen").
|
| 9 |
+
%%% @end
|
| 10 |
+
%%%-------------------------------------------------------------------
|
| 11 |
+
-module(hk_event_sup).
|
| 12 |
+
-behaviour(supervisor).
|
| 13 |
+
|
| 14 |
+
-export([start_link/0, init/1]).
|
| 15 |
+
|
| 16 |
+
start_link() ->
|
| 17 |
+
hk_sup_util:start_link_retry(
|
| 18 |
+
fun() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []) end).
|
| 19 |
+
|
| 20 |
+
init([]) ->
|
| 21 |
+
SupFlags = #{strategy => one_for_one, intensity => 10, period => 10},
|
| 22 |
+
Children = [
|
| 23 |
+
#{id => hk_event_bus,
|
| 24 |
+
start => {hk_event_bus, start_link, []},
|
| 25 |
+
restart => permanent,
|
| 26 |
+
shutdown => 5000,
|
| 27 |
+
type => worker,
|
| 28 |
+
modules => [hk_event_bus]}
|
| 29 |
+
],
|
| 30 |
+
{ok, {SupFlags, Children}}.
|