-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Gradualizer into an OTP application with supervision tree
- Loading branch information
1 parent
b03bc74
commit 27ceb1d
Showing
9 changed files
with
192 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
[kernel, | ||
stdlib | ||
]}, | ||
{mod, {gradualizer_app, []}}, | ||
{env,[ | ||
{providers, [rebar_prv_gradualizer]} | ||
]}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
%%%------------------------------------------------------------------- | ||
%%% @doc Gradualizer application | ||
%%%------------------------------------------------------------------- | ||
-module(gradualizer_app). | ||
|
||
-behaviour(application). | ||
|
||
%% Application callbacks | ||
-export([start/2, | ||
stop/1 | ||
]). | ||
|
||
%%%=================================================================== | ||
%%% Application callbacks | ||
%%%=================================================================== | ||
|
||
start(_StartType, _StartArgs) -> | ||
gradualizer_sup:start_link(). | ||
|
||
stop(_State) -> | ||
ok. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
%%%------------------------------------------------------------------- | ||
%%% @doc Main Gradualizer supervisor | ||
%%%------------------------------------------------------------------- | ||
-module(gradualizer_sup). | ||
|
||
-behaviour(supervisor). | ||
|
||
%% API | ||
-export([start_link/0]). | ||
|
||
%% Supervisor callbacks | ||
-export([init/1]). | ||
|
||
-define(SERVER, ?MODULE). | ||
|
||
%%=================================================================== | ||
%% API functions | ||
%%=================================================================== | ||
|
||
%% @doc Start the supervisor | ||
-spec start_link() -> {ok, Pid :: pid()} | | ||
{error, {already_started, Pid :: pid()}} | | ||
{error, {shutdown, term()}} | | ||
{error, term()} | | ||
ignore. | ||
start_link() -> | ||
supervisor:start_link({local, ?SERVER}, ?MODULE, []). | ||
|
||
%%=================================================================== | ||
%% Supervisor callbacks | ||
%%=================================================================== | ||
|
||
-spec init(Args :: term()) -> | ||
{ok, {SupFlags :: supervisor:sup_flags(), | ||
[ChildSpec :: supervisor:child_spec()]}} | | ||
ignore. | ||
init([]) -> | ||
SupFlags = #{strategy => one_for_one, | ||
intensity => 1, | ||
period => 5}, | ||
Children = [child(gradualizer_db), | ||
child(gradualizer_cache)], | ||
{ok, {SupFlags, Children}}. | ||
|
||
%%=================================================================== | ||
%% Internal functions | ||
%%=================================================================== | ||
|
||
child(Module) -> | ||
#{id => Module, | ||
start => {Module, start_link, []}, | ||
restart => permanent, | ||
shutdown => 5000, | ||
type => worker, | ||
modules => [Module]}. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters