./ct_report/coverage/mod_pubsub_db_backend.COVER.html

1 -module(mod_pubsub_db_backend).
2
3 -behaviour(mod_pubsub_db).
4
5 -export([init/2, stop/0]).
6 % Funs execution
7 -export([transaction/2, dirty/2]).
8 % Direct #pubsub_state access
9 -export([get_state/2,
10 get_states/1, get_states_by_lus/1, get_states_by_bare/1,
11 get_states_by_bare_and_full/1, get_idxs_of_own_nodes_with_pending_subs/1]).
12 % Node management
13 -export([
14 create_node/2,
15 del_node/1,
16 set_node/1,
17 find_node_by_id/1,
18 find_nodes_by_key/1,
19 find_node_by_name/2,
20 delete_node/1,
21 get_subnodes/2,
22 get_parentnodes_tree/2,
23 get_subnodes_tree/2
24 ]).
25 % Affiliations
26 -export([
27 set_affiliation/3,
28 get_affiliation/2
29 ]).
30 % Subscriptions
31 -export([
32 add_subscription/5,
33 set_subscription_opts/4,
34 get_node_subscriptions/1,
35 get_node_entity_subscriptions/2,
36 delete_subscription/3,
37 delete_all_subscriptions/2,
38 update_subscription/4
39 ]).
40 % Item ids in state
41 -export([
42 add_item/3,
43 remove_items/3,
44 remove_all_items/1
45 ]).
46 % Whole items
47 -export([
48 get_items/2,
49 get_item/2,
50 set_item/1,
51 del_item/2,
52 del_items/2
53 ]).
54
55 %% GDPR related
56 -export([
57 get_user_payloads/2,
58 get_user_nodes/2,
59 get_user_subscriptions/2,
60 delete_user_subscriptions/1,
61 find_nodes_by_affiliated_user/1
62 ]).
63
64 -define(MAIN_MODULE, mod_pubsub_db).
65
66 %%====================================================================
67 %% Behaviour callbacks
68 %%====================================================================
69
70 %% ------------------------ Backend start/stop ------------------------
71
72 init(HostType, Opts) ->
73 39 TrackedFuns = [create_node, del_node, get_state, get_states,
74 get_states_by_lus, get_states_by_bare,
75 get_items, get_item, set_item, add_item,
76 del_item, del_items,
77 set_node, find_node_by_id, find_nodes_by_key,
78 find_node_by_name, delete_node, get_subnodes,
79 get_subnodes_tree, get_parentnodes_tree],
80 39 mongoose_backend:init(global, ?MAIN_MODULE, TrackedFuns, Opts),
81 39 Args = [HostType, Opts],
82 39 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
83
84 -spec stop() -> ok.
85 stop() ->
86 39 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, []).
87
88
89 %% ------------------------ Fun execution ------------------------
90
91 transaction(Fun, ErrorDebug) ->
92 389 Args = [Fun, ErrorDebug],
93 389 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
94
95 dirty(Fun, ErrorDebug) ->
96 1730 Args = [Fun, ErrorDebug],
97 1730 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
98
99 %% ------------------------ Direct #pubsub_state access ------------------------
100 get_state(Nidx, LJID) ->
101 266 Args = [Nidx, LJID],
102 266 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
103
104 get_states(Nidx) ->
105 10 Args = [Nidx],
106 10 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
107
108 get_states_by_lus(LUS) ->
109 15 Args = [LUS],
110 15 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
111
112 get_states_by_bare(LUS) ->
113 421 Args = [LUS],
114 421 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
115
116 get_states_by_bare_and_full(LJID) ->
117 552 Args = [LJID],
118 552 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
119
120 get_idxs_of_own_nodes_with_pending_subs(LJID) ->
121 2 Args = [LJID],
122 2 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
123
124 %% ------------------------ Direct #pubsub_item access ------------------------
125
126 get_items(Nidx, Opts) ->
127 50 Args = [Nidx, Opts],
128 50 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
129
130 get_item(Nidx, ItemId) ->
131 127 Args = [Nidx, ItemId],
132 127 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
133
134 set_item(Item) ->
135
:-(
Args = [Item],
136
:-(
mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
137
138 del_item(Nidx, ItemId) ->
139 8 Args = [Nidx, ItemId],
140 8 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
141
142 del_items(Nidx, ItemIds) ->
143 123 Args = [Nidx, ItemIds],
144 123 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
145
146 % ------------------- Node management --------------------------------
147
148 create_node(Nidx, LJID) ->
149 229 Args = [Nidx, LJID],
150 229 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
151
152 del_node(Nidx) ->
153 156 Args = [Nidx],
154 156 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
155
156 set_node(Node) ->
157 240 Args = [Node],
158 240 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
159
160 find_node_by_id(Nidx) ->
161 270 Args = [Nidx],
162 270 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
163
164 find_node_by_name(Key, Node) ->
165 1277 Args = [Key, Node],
166 1277 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
167
168 find_nodes_by_key(Key) ->
169 30 Args = [Key],
170 30 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
171
172 delete_node(Node) ->
173 156 Args = [Node],
174 156 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
175
176 get_subnodes(Key, Node) ->
177 100 Args = [Key, Node],
178 100 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
179
180 get_parentnodes_tree(Key, Node) ->
181 309 Args = [Key, Node],
182 309 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
183
184 get_subnodes_tree(Key, Node) ->
185 63 Args = [Key, Node],
186 63 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
187
188 % ------------------- Affiliations --------------------------------
189
190 set_affiliation(Nidx, LJID, Affiliation) ->
191 64 Args = [Nidx, LJID, Affiliation],
192 64 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
193
194 get_affiliation(Nidx, LJID) ->
195 517 Args = [Nidx, LJID],
196 517 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
197
198 % ------------------- Subscriptions --------------------------------
199
200 add_subscription(Nidx, LJID, Sub, SubId, SubOpts) ->
201 93 Args = [Nidx, LJID, Sub, SubId, SubOpts],
202 93 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
203
204 set_subscription_opts(Nidx, LJID, SubId, Opts) ->
205 4 Args = [Nidx, LJID, SubId, Opts],
206 4 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
207
208 get_node_subscriptions(Nidx) ->
209 574 Args = [Nidx],
210 574 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
211
212 get_node_entity_subscriptions(Nidx, LJID) ->
213 208 Args = [Nidx, LJID],
214 208 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
215
216 delete_subscription(Nidx, LJID, SubId) ->
217 4 Args = [Nidx, LJID, SubId],
218 4 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
219
220 delete_all_subscriptions(Nidx, LJID) ->
221 7 Args = [Nidx, LJID],
222 7 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
223
224 update_subscription(Nidx, LJID, Subscription, SubId) ->
225 3 Args = [Nidx, LJID, Subscription, SubId],
226 3 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
227
228 % ------------------- Items --------------------------------
229
230 add_item(Nidx, LJID, Item) ->
231 119 Args = [Nidx, LJID, Item],
232 119 mongoose_backend:call_tracked(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
233
234 remove_items(Nidx, LJID, ItemIds) ->
235 127 Args = [Nidx, LJID, ItemIds],
236 127 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
237
238 remove_all_items(Nidx) ->
239 4 Args = [Nidx],
240 4 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
241
242 % ------------------- GDPR-related --------------------------------
243
244 get_user_payloads(LUser, LServer) ->
245 21 Args = [LUser, LServer],
246 21 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
247
248 get_user_nodes(LUser, LServer) ->
249 21 Args = [LUser, LServer],
250 21 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
251
252 get_user_subscriptions(LUser, LServer) ->
253 21 Args = [LUser, LServer],
254 21 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
255
256 delete_user_subscriptions(LJID) ->
257 78 Args = [LJID],
258 78 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
259
260 find_nodes_by_affiliated_user(LJID) ->
261 78 Args = [LJID],
262 78 mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
Line Hits Source