Added PeerManagement.Type = 'etcd' #506
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.
Which problem is this PR solving?
This PR offers an alternative to Redis for centralized peer discovery using an etcd service.
Short description of the changes
Close(ctx context.Context) error
to thePeers
interface to allow for clean shutdown and de-registration of an instance from the cluster.Race condition in Peers interface design
Since
peer.NewPeers()
launches async go routines for both Redis and etcd, it is possible that a callback could occur before we callRegisterUpdatedPeersCallback()
to register the call back, therefore missing the initial callback.For example, in
etcd_test.go
we should be able to assert thatp0
will receive 3 callbacks, one for itself, and then 2 for each additional member. However, because of the race condition, we might only get 2 callbacks.We could change the
Peers
interface to instead register a callback duringpeer.NewPeers(conf, cb)
call OR we could add aStart()
method to thePeers
interface, such that users wouldRegisterUpdatedPeersCallback()
and then callStart()
when ready to participate in receiving updates.