rabbit_peer_discovery: Add pre/post discovery steps #10763
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
The Consul peer discovery backend needs to create a session before it can acquire a lock. This session is also required for nodes to discover each other.
This session was created as part of the lock callback. However, after pull request #9797, the lock was only acquired if and when a node had ot join another one. Thus, after the actual discovery phase. This broke Consul peer discovery because the discovery was performed before that Consul session was created.
How
We introduce two new callbacks,
pre_discovery/0
andpost_discovery/1
to allow a backend to perform actions before and after the whole discover/lock/join process. The new callbacks are used by the Consul peer discovery backend to create and delete that session.To remain compatible with other peer discovery backend, the new callbacks are optional.
Fixes #10760.