diff options
author | Michael Klishin <michael@clojurewerkz.org> | 2020-03-16 12:38:42 +0300 |
---|---|---|
committer | Michael Klishin <michael@clojurewerkz.org> | 2020-03-16 12:38:42 +0300 |
commit | 8e307888054028ce5a6c37f457dd2634f0dd2968 (patch) | |
tree | 822ec15143888256235fa6018292f37928142561 | |
parent | 8a4fa255ddef8e6e488c89dc1735d9a6d0243a9c (diff) | |
download | rabbitmq-server-git-8e307888054028ce5a6c37f457dd2634f0dd2968.tar.gz |
Classic config peer discovery: conditionally support registration
If registration is supported, a randomized delay will be injected. It makes
sense to support it in this config, in fact, our own test suites are evidence
of that: they start all nodes in parallel.
However, this backend is used by default so even a blank single node would
then wait on a delay that serves no purpose. So we make this conditional:
if no peer nodes are configured we don't want to induce any delays.
Pair: @dumbbell.
-rw-r--r-- | src/rabbit_peer_discovery_classic_config.erl | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/rabbit_peer_discovery_classic_config.erl b/src/rabbit_peer_discovery_classic_config.erl index e5f41c9594..2183cda04d 100644 --- a/src/rabbit_peer_discovery_classic_config.erl +++ b/src/rabbit_peer_discovery_classic_config.erl @@ -37,7 +37,9 @@ list_nodes() -> -spec supports_registration() -> boolean(). supports_registration() -> - false. + %% If we don't have any nodes configured, skip randomized delay and similar operations + %% as we don't want to delay startup for no reason. MK. + has_any_peer_nodes_configured(). -spec register() -> ok. @@ -63,3 +65,19 @@ lock(_Node) -> unlock(_Data) -> ok. + +%% +%% Helpers +%% + +has_any_peer_nodes_configured() -> + case application:get_env(rabbit, cluster_nodes, []) of + {[], _NodeType} -> + false; + {Nodes, _NodeType} when is_list(Nodes) -> + true; + [] -> + false; + Nodes when is_list(Nodes) -> + true + end. |