./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 105 ets:new(?TABLE, [set, named_table, public]).
12
13 set(Val) ->
14 349 ets:insert(?TABLE, {state, Val}).
15
16 get(Def) ->
17 601 try
18 601 ets:lookup_element(?MODULE, state, 2)
19 105 catch _:_:_ -> Def
20 end.
21
22 reset() ->
23 8 ets:insert(?TABLE, {state, reset}).
Line Hits Source