./ct_report/coverage/mod_last_backend.COVER.html

1 %% Just a proxy interface module between the main mod_last module and
2 %% the backend modules (i.e. mod_last_rdbms, mod_last_mnesia...).
3 -module(mod_last_backend).
4
5 -export([init/2,
6 get_last/3,
7 count_active_users/3,
8 set_last_info/5,
9 session_cleanup/5,
10 remove_user/3,
11 remove_domain/2,
12 sessions_cleanup/2]).
13
14 -define(MAIN_MODULE, mod_last).
15
16 -callback init(mongooseim:host_type(), gen_mod:module_opts()) -> ok.
17
18 -callback get_last(mongooseim:host_type(), jid:luser(), jid:lserver()) ->
19 {ok, mod_last:timestamp(), mod_last:status()} | {error, term()} | not_found.
20
21 -callback count_active_users(mongooseim:host_type(), jid:lserver(), mod_last:timestamp()) ->
22 non_neg_integer().
23
24 -callback set_last_info(
25 mongooseim:host_type(),
26 jid:luser(),
27 jid:lserver(),
28 mod_last:timestamp(),
29 mod_last:status()) -> ok | {error, term()}.
30
31 -callback session_cleanup(
32 mongooseim:host_type(),
33 jid:luser(),
34 jid:lserver(),
35 mod_last:timestamp(),
36 mod_last:status()) -> ok | {error, term()}.
37
38 -callback sessions_cleanup(mongooseim:host_type(), [ejabberd_sm:session()]) ->
39 ok | {error, term()}.
40
41 -callback remove_user(mongooseim:host_type(), jid:luser(), jid:lserver()) ->
42 ok | {error, term()}.
43
44 -callback remove_domain(mongooseim:host_type(), jid:lserver()) ->
45 ok | {error, term()}.
46
47 -spec init(mongooseim:host_type(), gen_mod:module_opts()) -> ok.
48 init(HostType, Opts) ->
49 10 TrackedFuns = [get_last, set_last_info],
50 10 mongoose_backend:init(HostType, ?MAIN_MODULE, TrackedFuns, Opts),
51 10 Args = [HostType, Opts],
52 10 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
53
54 -spec get_last(mongooseim:host_type(), jid:luser(), jid:lserver()) ->
55 {ok, mod_last:timestamp(), mod_last:status()} | {error, term()} | not_found.
56 get_last(HostType, LUser, LServer) ->
57 9 Args = [HostType, LUser, LServer],
58 9 mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
59
60 -spec count_active_users(mongooseim:host_type(), jid:lserver(), mod_last:timestamp()) ->
61 non_neg_integer().
62 count_active_users(HostType, LServer, Timestamp) ->
63 6 Args = [HostType, LServer, Timestamp],
64 6 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
65
66 -spec set_last_info(
67 mongooseim:host_type(),
68 jid:luser(),
69 jid:lserver(),
70 mod_last:timestamp(),
71 mod_last:status()) -> ok | {error, term()}.
72 set_last_info(HostType, LUser, LServer, Timestamp, Status) ->
73 42 Args = [HostType, LUser, LServer, Timestamp, Status],
74 42 mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
75
76 -spec session_cleanup(
77 mongooseim:host_type(),
78 jid:luser(),
79 jid:lserver(),
80 mod_last:timestamp(),
81 mod_last:status()) -> ok | {error, term()}.
82 session_cleanup(HostType, LUser, LServer, Timestamp, Status) ->
83 345 Args = [HostType, LUser, LServer, Timestamp, Status],
84 345 mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
85
86 -spec remove_user(mongooseim:host_type(), jid:luser(), jid:lserver()) ->
87 ok | {error, term()}.
88 remove_user(HostType, LUser, LServer) ->
89 22 Args = [HostType, LUser, LServer],
90 22 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
91
92 -spec remove_domain(mongooseim:host_type(), jid:lserver()) ->
93 ok | {error, term()}.
94 remove_domain(HostType, LServer) ->
95
:-(
Args = [HostType, LServer],
96
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
97
98 -spec sessions_cleanup(mongooseim:host_type(), [ejabberd_sm:session()]) ->
99 ok | {error, term()}.
100 sessions_cleanup(HostType, Sessions) ->
101 1 Args = [HostType, Sessions],
102 1 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
Line Hits Source