./ct_report/coverage/mod_bosh_cets.COVER.html

1 -module(mod_bosh_cets).
2
3 -behaviour(mod_bosh_backend).
4
5 %% mod_bosh_backend callbacks
6 -export([start/0,
7 create_session/1,
8 delete_session/1,
9 get_session/1,
10 get_sessions/0,
11 node_cleanup/1]).
12
13 -include("mod_bosh.hrl").
14
15 -define(TABLE, cets_bosh).
16
17 -spec start() -> any().
18 start() ->
19
:-(
cets:start(?TABLE, #{keypos => 2}),
20
:-(
cets_discovery:add_table(mongoose_cets_discovery, ?TABLE).
21
22 %% Session key (sid) is unique, so we don't expect conflicts
23 %% So, the confict resolution could be avoided
24 -spec create_session(mod_bosh:session()) -> any().
25 create_session(Session) ->
26
:-(
cets:insert(?TABLE, Session).
27
28 -spec delete_session(mod_bosh:sid()) -> any().
29 delete_session(Sid) ->
30
:-(
cets:delete(?TABLE, Sid).
31
32 -spec get_session(mod_bosh:sid()) -> [mod_bosh:session()].
33 get_session(Sid) ->
34
:-(
ets:lookup(?TABLE, Sid).
35
36 -spec get_sessions() -> [mod_bosh:session()].
37 get_sessions() ->
38
:-(
ets:tab2list(?TABLE).
39
40 -spec node_cleanup(atom()) -> any().
41 node_cleanup(Node) ->
42
:-(
Guard = {'==', {node, '$1'}, Node},
43
:-(
R = {'_', '_', '$1'},
44
:-(
cets:ping_all(?TABLE),
45 %% We don't need to replicate deletes
46 %% We remove the local content here
47
:-(
ets:select_delete(?TABLE, [{R, [Guard], [true]}]),
48
:-(
ok.
Line Hits Source