./ct_report/coverage/mod_muc_online_backend.COVER.html

1 -module(mod_muc_online_backend).
2
3 -export([start/2,
4 stop/1,
5 register_room/4,
6 room_destroyed/4,
7 find_room_pid/3,
8 get_online_rooms/2,
9 node_cleanup/2,
10 clear_table/1]).
11
12 %% Used in tests
13 -ignore_xref([clear_table/1]).
14
15 -define(MAIN_MODULE, mod_muc_online).
16
17 %% Callbacks
18
19 -callback start(mongooseim:host_type(), gen_mod:module_opts()) -> ok.
20
21 -callback stop(mongooseim:host_type()) -> ok.
22
23 -callback register_room(
24 HostType :: mongooseim:host_type(),
25 MucHost :: jid:lserver(),
26 Room :: mod_muc:room(),
27 Pid :: pid()) -> ok | {exists, pid()} | {error, term()}.
28
29 -callback room_destroyed(mongooseim:host_type(), jid:lserver(), mod_muc:room(), pid()) -> ok.
30
31 -callback find_room_pid(mongooseim:host_type(), jid:lserver(), mod_muc:room()) ->
32 {ok, pid()} | {error, not_found}.
33
34 -callback get_online_rooms(mongooseim:host_type(), jid:lserver()) ->
35 [mod_muc:muc_online_room()].
36
37 -callback node_cleanup(mongooseim:host_type(), node()) -> ok.
38
39 -callback clear_table(mongooseim:host_type()) -> ok.
40
41 %% API Functions
42
43 -spec start(mongooseim:host_type(), gen_mod:module_opts()) -> any().
44 start(HostType, Opts = #{online_backend := Backend}) ->
45 38 mongoose_backend:init(HostType, ?MAIN_MODULE, tracked_funs(), #{backend => Backend}),
46 38 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, [HostType, Opts]).
47
48 stop(HostType) ->
49 38 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, [HostType]).
50
51 -spec tracked_funs() -> [atom()].
52 tracked_funs() ->
53 38 [register_room,
54 room_destroyed,
55 get_online_rooms].
56
57 -spec register_room(
58 HostType :: mongooseim:host_type(),
59 MucHost :: jid:lserver(),
60 Room :: mod_muc:room(),
61 Pid :: pid()) -> ok | {exists, pid()} | {error, term()}.
62 register_room(HostType, MucHost, Room, Pid) ->
63 616 Args = [HostType, MucHost, Room, Pid],
64 616 mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
65
66 -spec room_destroyed(mongooseim:host_type(), jid:lserver(), mod_muc:room(), pid()) -> ok.
67 room_destroyed(HostType, MucHost, Room, Pid) ->
68 602 Args = [HostType, MucHost, Room, Pid],
69 602 mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
70
71 -spec find_room_pid(mongooseim:host_type(), jid:lserver(), mod_muc:room()) ->
72 {ok, pid()} | {error, not_found}.
73 find_room_pid(HostType, MucHost, Room) ->
74 4027 Args = [HostType, MucHost, Room],
75 4027 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
76
77 -spec get_online_rooms(mongooseim:host_type(), jid:lserver()) ->
78 [mod_muc:muc_online_room()].
79 get_online_rooms(HostType, MucHost) ->
80 44 Args = [HostType, MucHost],
81 44 mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
82
83 -spec node_cleanup(mongooseim:host_type(), node()) -> ok.
84 node_cleanup(HostType, Node) ->
85
:-(
Args = [HostType, Node],
86
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
87
88 clear_table(HostType) ->
89 18 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, [HostType]).
Line Hits Source