1 |
|
-module(mongoose_component_backend). |
2 |
|
|
3 |
|
-type external_component() :: mongoose_component:external_component(). |
4 |
|
|
5 |
|
-callback init(map()) -> any(). |
6 |
|
|
7 |
|
-callback node_cleanup(node()) -> ok. |
8 |
|
|
9 |
|
-callback register_components(Components :: [external_component()]) -> ok. |
10 |
|
|
11 |
|
-callback unregister_components(Components :: [external_component()]) -> ok. |
12 |
|
|
13 |
|
-callback lookup_component(Domain :: jid:lserver()) -> [external_component()]. |
14 |
|
|
15 |
|
-callback lookup_component(Domain :: jid:lserver(), Node :: node()) -> [external_component()]. |
16 |
|
|
17 |
|
-callback get_all_components(ReturnHidden :: mongoose_component:return_hidden()) -> [jid:lserver()]. |
18 |
|
|
19 |
|
-export([init/1, |
20 |
|
node_cleanup/1, |
21 |
|
register_components/1, |
22 |
|
unregister_components/1, |
23 |
|
lookup_component/1, |
24 |
|
lookup_component/2, |
25 |
|
get_all_components/1]). |
26 |
|
|
27 |
|
-ignore_xref([behaviour_info/1]). |
28 |
|
|
29 |
|
-define(MAIN_MODULE, mongoose_component). |
30 |
|
|
31 |
|
-spec init(map()) -> any(). |
32 |
|
init(Opts) -> |
33 |
104 |
Args = [Opts], |
34 |
104 |
mongoose_backend:init(global, ?MAIN_MODULE, [], Opts), |
35 |
104 |
mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |
36 |
|
|
37 |
|
-spec node_cleanup(node()) -> ok. |
38 |
|
node_cleanup(Node) -> |
39 |
8 |
Args = [Node], |
40 |
8 |
mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |
41 |
|
|
42 |
|
-spec register_components(Components :: [external_component()]) -> ok. |
43 |
|
register_components(Components) -> |
44 |
28 |
Args = [Components], |
45 |
28 |
mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |
46 |
|
|
47 |
|
-spec unregister_components(Components :: [external_component()]) -> ok. |
48 |
|
unregister_components(Components) -> |
49 |
28 |
Args = [Components], |
50 |
28 |
mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |
51 |
|
|
52 |
|
-spec lookup_component(Domain :: jid:lserver()) -> [external_component()]. |
53 |
|
lookup_component(Domain) -> |
54 |
395 |
Args = [Domain], |
55 |
395 |
mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |
56 |
|
|
57 |
|
-spec lookup_component(Domain :: jid:lserver(), Node :: node()) -> [external_component()]. |
58 |
|
lookup_component(Domain, Node) -> |
59 |
359 |
Args = [Domain, Node], |
60 |
359 |
mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |
61 |
|
|
62 |
|
-spec get_all_components(ReturnHidden :: mongoose_component:return_hidden()) -> [jid:lserver()]. |
63 |
|
get_all_components(ReturnHidden) -> |
64 |
86 |
Args = [ReturnHidden], |
65 |
86 |
mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |