./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 remove_user/3,
10 remove_domain/2]).
11
12 -define(MAIN_MODULE, mod_last).
13
14 -callback init(mongooseim:host_type(), gen_mod:module_opts()) -> ok.
15
16 -callback get_last(mongooseim:host_type(), jid:luser(), jid:lserver()) ->
17 {ok, mod_last:timestamp(), mod_last:status()} | {error, term()} | not_found.
18
19 -callback count_active_users(mongooseim:host_type(), jid:lserver(), mod_last:timestamp()) ->
20 non_neg_integer().
21
22 -callback set_last_info(
23 mongooseim:host_type(),
24 jid:luser(),
25 jid:lserver(),
26 mod_last:timestamp(),
27 mod_last:status()) -> ok | {error, term()}.
28
29 -callback remove_user(mongooseim:host_type(), jid:luser(), jid:lserver()) ->
30 ok | {error, term()}.
31
32 -callback remove_domain(mongooseim:host_type(), jid:lserver()) ->
33 ok | {error, term()}.
34
35 -spec init(mongooseim:host_type(), gen_mod:module_opts()) -> ok.
36 init(HostType, Opts) ->
37
:-(
TrackedFuns = [get_last, set_last_info],
38
:-(
mongoose_backend:init(HostType, ?MAIN_MODULE, TrackedFuns, Opts),
39
:-(
Args = [HostType, Opts],
40
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
41
42 -spec get_last(mongooseim:host_type(), jid:luser(), jid:lserver()) ->
43 {ok, mod_last:timestamp(), mod_last:status()} | {error, term()} | not_found.
44 get_last(HostType, LUser, LServer) ->
45
:-(
Args = [HostType, LUser, LServer],
46
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
47
48 -spec count_active_users(mongooseim:host_type(), jid:lserver(), mod_last:timestamp()) ->
49 non_neg_integer().
50 count_active_users(HostType, LServer, Timestamp) ->
51
:-(
Args = [HostType, LServer, Timestamp],
52
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
53
54 -spec set_last_info(
55 mongooseim:host_type(),
56 jid:luser(),
57 jid:lserver(),
58 mod_last:timestamp(),
59 mod_last:status()) -> ok | {error, term()}.
60 set_last_info(HostType, LUser, LServer, Timestamp, Status) ->
61
:-(
Args = [HostType, LUser, LServer, Timestamp, Status],
62
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
63
64 -spec remove_user(mongooseim:host_type(), jid:luser(), jid:lserver()) ->
65 ok | {error, term()}.
66 remove_user(HostType, LUser, LServer) ->
67
:-(
Args = [HostType, LUser, LServer],
68
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
69
70 -spec remove_domain(mongooseim:host_type(), jid:lserver()) ->
71 ok | {error, term()}.
72 remove_domain(HostType, LServer) ->
73
:-(
Args = [HostType, LServer],
74
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
Line Hits Source