Skip to content

Commit

Permalink
[#13] OTP < 18 not supported. Allow backwards compatibility from OTP …
Browse files Browse the repository at this point in the history
…17 onwards.
  • Loading branch information
cabol committed Jun 6, 2016
1 parent 216dd76 commit f6e8d34
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/shards_owner_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,33 @@ init([Name, Options, NumShards]) ->
ok = init_shards_dist(Name, Module),

% launch shards supervisor
supervise(Children, #{strategy => one_for_one}).
supervise(Children).

%%%===================================================================
%%% Internal functions
%%%===================================================================

%% @private
child(Type, Module, Args, Spec) when is_map(Spec) ->
#{id => maps:get(id, Spec, Module),
start => maps:get(start, Spec, {Module, start_link, Args}),
restart => maps:get(restart, Spec, permanent),
shutdown => maps:get(shutdown, Spec, 5000),
type => Type,
modules => maps:get(modules, Spec, [Module])}.
{maps:get(id, Spec, Module),
maps:get(start, Spec, {Module, start_link, Args}),
maps:get(restart, Spec, permanent),
maps:get(shutdown, Spec, 5000),
Type,
maps:get(modules, Spec, [Module])}.

%% @private
supervise(Children, SupFlags) ->
supervise(Children) ->
supervise(Children, #{}).

%% @private
supervise(Children, SupFlagsMap) ->
assert_unique_ids([Id || #{id := Id} <- Children]),
SupFlags = {
maps:get(strategy, SupFlagsMap, one_for_one),
maps:get(intensity, SupFlagsMap, 1),
maps:get(period, SupFlagsMap, 5)
},
{ok, {SupFlags, Children}}.

%% @private
Expand Down

0 comments on commit f6e8d34

Please sign in to comment.