./ct_report/coverage/ejabberd_sm_backend.COVER.html

1 %% Generic module to access SM backend modules
2 -module(ejabberd_sm_backend).
3
4 -callback init(map()) ->
5 any().
6 -callback get_sessions() ->
7 [ejabberd_sm:session()].
8 -callback get_sessions(jid:server()) ->
9 [ejabberd_sm:session()].
10 -callback get_sessions(jid:user(), jid:server()) ->
11 [ejabberd_sm:session()].
12 -callback get_sessions(jid:user(), jid:server(), jid:resource()) ->
13 [ejabberd_sm:session()].
14 -callback set_session(jid:luser(),
15 jid:lserver(),
16 jid:lresource(),
17 ejabberd_sm:session()) ->
18 ok | {error, term()}.
19 -callback delete_session(ejabberd_sm:sid(),
20 jid:user(),
21 jid:server(),
22 jid:resource()) -> ok.
23 -callback cleanup(Node :: atom()) -> any().
24 -callback total_count() -> integer().
25 -callback unique_count() -> integer().
26
27 -export([init/1,
28 get_sessions/0, get_sessions/1, get_sessions/2, get_sessions/3,
29 set_session/4, delete_session/4, cleanup/1,
30 total_count/0, unique_count/0]).
31
32 -ignore_xref([cleanup/1, behaviour_info/1]).
33
34 -define(MAIN_MODULE, ejabberd_sm).
35
36 -spec init(map()) -> any().
37 init(Opts) ->
38 104 Args = [Opts],
39 104 mongoose_backend:init(global, ?MAIN_MODULE, [], Opts),
40 104 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
41
42 -spec get_sessions() -> [ejabberd_sm:session()].
43 get_sessions() ->
44 118 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, []).
45
46 -spec get_sessions(jid:server()) -> [ejabberd_sm:session()].
47 get_sessions(Server) ->
48 66 Args = [Server],
49 66 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
50
51 -spec get_sessions(jid:user(), jid:server()) ->
52 [ejabberd_sm:session()].
53 get_sessions(User, Server) ->
54 44140 Args = [User, Server],
55 44140 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
56
57 -spec get_sessions(jid:user(),
58 jid:server(),
59 jid:resource()) ->
60 [ejabberd_sm:session()].
61 get_sessions(User, Server, Resource) ->
62 25950 Args = [User, Server, Resource],
63 25950 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
64
65 -spec set_session(User :: jid:user(),
66 Server :: jid:server(),
67 Resource :: jid:resource(),
68 Session :: ejabberd_sm:session()) -> ok | {error, term()}.
69 set_session(User, Server, Resource, Session) ->
70 12911 Args = [User, Server, Resource, Session],
71 12911 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
72
73 -spec delete_session(Sid :: ejabberd_sm:sid(),
74 User :: jid:user(),
75 Server :: jid:server(),
76 Resource :: jid:resource()) -> ok.
77 delete_session(Sid, User, Server, Resource) ->
78 6586 Args = [Sid, User, Server, Resource],
79 6586 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
80
81 -spec cleanup(Node :: atom()) -> any().
82 cleanup(Node) ->
83 8 Args = [Node],
84 8 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
85
86 -spec total_count() -> integer().
87 total_count() ->
88 178 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, []).
89
90 -spec unique_count() -> integer().
91 unique_count() ->
92 171 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, []).
Line Hits Source