./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 33 cets:start(?TABLE, #{keypos => 2}),
20 33 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 129 cets:insert(?TABLE, Session).
27
28 -spec delete_session(mod_bosh:sid()) -> any().
29 delete_session(Sid) ->
30 129 cets:delete(?TABLE, Sid).
31
32 -spec get_session(mod_bosh:sid()) -> [mod_bosh:session()].
33 get_session(Sid) ->
34 1940 ets:lookup(?TABLE, Sid).
35
36 -spec get_sessions() -> [mod_bosh:session()].
37 get_sessions() ->
38 121 ets:tab2list(?TABLE).
39
40 -spec node_cleanup(atom()) -> any().
41 node_cleanup(Node) ->
42
:-(
Guard = {'==', {node, '$2'}, Node},
43
:-(
R = {'_', '$1', '$2'},
44
:-(
cets:ping_all(?TABLE),
45
:-(
Keys = ets:select(?TABLE, [{R, [Guard], ['$1']}]),
46
:-(
cets:delete_many(?TABLE, Keys).
Line Hits Source