|
20 | 20 | %% API
|
21 | 21 | %%
|
22 | 22 |
|
23 |
| --export([discover_cluster_nodes/0, backend/0, node_type/0, |
| 23 | +-export([maybe_init/0, discover_cluster_nodes/0, backend/0, node_type/0, |
24 | 24 | normalize/1, format_discovered_nodes/1, log_configured_backend/0,
|
25 | 25 | register/0, unregister/0, maybe_register/0, maybe_unregister/0,
|
26 | 26 | maybe_inject_randomized_delay/0, lock/0, unlock/1]).
|
@@ -88,6 +88,22 @@ lock_acquisition_failure_mode() ->
|
88 | 88 | log_configured_backend() ->
|
89 | 89 | rabbit_log:info("Configured peer discovery backend: ~s~n", [backend()]).
|
90 | 90 |
|
| 91 | +maybe_init() -> |
| 92 | + Backend = backend(), |
| 93 | + case erlang:function_exported(Backend, init, 0) of |
| 94 | + true -> |
| 95 | + rabbit_log:debug("Peer discovery backend supports initialisation."), |
| 96 | + case Backend:init() of |
| 97 | + ok -> |
| 98 | + rabbit_log:debug("Peer discovery backend initialisation succeeded."), |
| 99 | + ok; |
| 100 | + {error, Error} -> |
| 101 | + rabbit_log:warn("Peer discovery backend initialisation failed: ~p.", [Error]), |
| 102 | + ok |
| 103 | + end; |
| 104 | + false -> ok |
| 105 | + end. |
| 106 | + |
91 | 107 |
|
92 | 108 | -spec discover_cluster_nodes() -> {ok, Nodes :: list()} |
|
93 | 109 | {ok, {Nodes :: list(), NodeType :: rabbit_types:node_type()}} |
|
|
0 commit comments