./ct_report/coverage/mongoose_loader_state.COVER.html

1 %% This module contains the state of mongoose_domain_loader between calls.
2 -module(mongoose_loader_state).
3 -export([init/0, set/1, get/1, reset/0]).
4
5 -define(TABLE, ?MODULE).
6
7 %% Called by mongoose_domain_core
8 %% The loader state lives till the core process lives.
9 %% This means it survives service_domain_db restarts.
10 init() ->
11 348 ets:new(?TABLE, [set, named_table, public]).
12
13 set(Val) ->
14 568 ets:insert(?TABLE, {state, Val}).
15
16 get(Def) ->
17 968 try
18 968 ets:lookup_element(?MODULE, state, 2)
19 336 catch _:_:_ -> Def
20 end.
21
22 reset() ->
23 1 ets:insert(?TABLE, {state, reset}).
Line Hits Source