./ct_report/coverage/mod_stream_management_backend.COVER.html

1 -module(mod_stream_management_backend).
2 -export([init/2,
3 register_smid/3,
4 unregister_smid/2,
5 get_sid/2]).
6
7 -export([read_stale_h/2,
8 write_stale_h/3,
9 delete_stale_h/2]).
10
11 -define(MAIN_MODULE, mod_stream_management).
12
13 %% ----------------------------------------------------------------------
14 %% Callbacks
15 %% (exactly the same as specs in this module)
16
17 -callback init(HostType, Opts) -> ok when
18 HostType :: mongooseim:host_type(),
19 Opts :: gen_mod:module_opts().
20
21 -callback register_smid(HostType, SMID, SID) ->
22 ok | {error, term()} when
23 HostType :: mongooseim:host_type(),
24 SMID :: mod_stream_management:smid(),
25 SID :: ejabberd_sm:sid().
26
27 -callback unregister_smid(mongooseim:host_type(), ejabberd_sm:sid()) ->
28 {ok, SMID :: mod_stream_management:smid()} | {error, smid_not_found}.
29
30 -callback get_sid(mongooseim:host_type(), mod_stream_management:smid()) ->
31 {sid, ejabberd_sm:sid()} | {error, smid_not_found}.
32
33 %% stale_h functions
34
35 -callback read_stale_h(HostType, SMID) ->
36 {stale_h, non_neg_integer()} | {error, smid_not_found} when
37 HostType :: mongooseim:host_type(),
38 SMID :: mod_stream_management:smid().
39
40 -callback write_stale_h(HostType, SMID, H) -> ok | {error, any()} when
41 HostType :: mongooseim:host_type(),
42 SMID :: mod_stream_management:smid(),
43 H :: non_neg_integer().
44
45 -callback delete_stale_h(HostType, SMID) -> ok | {error, any()} when
46 HostType :: mongooseim:host_type(),
47 SMID :: mod_stream_management:smid().
48
49 %% ----------------------------------------------------------------------
50 %% API Functions
51
52 -spec init(HostType, Opts) -> ok when
53 HostType :: mongooseim:host_type(),
54 Opts :: gen_mod:module_opts().
55 init(HostType, Opts) ->
56 383 TrackedFuns = [],
57 383 mongoose_backend:init(HostType, ?MAIN_MODULE, TrackedFuns, Opts),
58 383 Args = [HostType, Opts],
59 383 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
60
61 -spec register_smid(HostType, SMID, SID) ->
62 ok | {error, term()} when
63 HostType :: mongooseim:host_type(),
64 SMID :: mod_stream_management:smid(),
65 SID :: ejabberd_sm:sid().
66 register_smid(HostType, SMID, SID) ->
67 44 Args = [HostType, SMID, SID],
68 44 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
69
70 -spec unregister_smid(mongooseim:host_type(), ejabberd_sm:sid()) ->
71 {ok, SMID :: mod_stream_management:smid()} | {error, smid_not_found}.
72 unregister_smid(HostType, SID) ->
73 2704 Args = [HostType, SID],
74 2704 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
75
76 -spec get_sid(mongooseim:host_type(), mod_stream_management:smid()) ->
77 {sid, ejabberd_sm:sid()} | {error, smid_not_found}.
78 get_sid(HostType, SMID) ->
79 18 Args = [HostType, SMID],
80 18 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
81
82 %% stale_h functions
83
84 -spec read_stale_h(HostType, SMID) ->
85 {stale_h, non_neg_integer()} | {error, smid_not_found} when
86 HostType :: mongooseim:host_type(),
87 SMID :: mod_stream_management:smid().
88 read_stale_h(HostType, SMID) ->
89 25 Args = [HostType, SMID],
90 25 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
91
92 -spec write_stale_h(HostType, SMID, H) -> ok | {error, any()} when
93 HostType :: mongooseim:host_type(),
94 SMID :: mod_stream_management:smid(),
95 H :: non_neg_integer().
96 write_stale_h(HostType, SMID, H) ->
97 8 Args = [HostType, SMID, H],
98 8 mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
99
100 -spec delete_stale_h(HostType, SMID) -> ok | {error, any()} when
101 HostType :: mongooseim:host_type(),
102 SMID :: mod_stream_management:smid().
103 delete_stale_h(HostType, SMID) ->
104
:-(
Args = [HostType, SMID],
105
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
Line Hits Source