Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Leadership] Enable implementing leadership decisions outside core lib #1117

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ktoso
Copy link
Member

@ktoso ktoso commented Apr 24, 2023

Motivation:

It was not possible to implement a "real" leadership election using whatever mechanism one could dream up using the current exposed methods.

We now expose assumeLeader which makes the local assumption change, and therefore it is possible to call that method from real leadership election implementations. We should offer more of those AND document how to implement your custom one -- the example impl could be a bully implementation for example.

The test uses a dumb implementation that is only there for showcasing how to use the receptionist to discover peers in the process.

Modifications:

  • LeaderElection -> LegacyLeaderElection, because it was using NIO Futures
  • add cluster.assumeLeader
  • add a few methods to await waitToBecomeLeader and waitForLeader(atLeast:within:)

Result:

Ability to implement ANY leadership election mechanism and inform the cluster node which node should be considered the leader.

The leader decision is NOT gossiped. This is entirely up to the leader election mechanism to propagate this information.

@ktoso
Copy link
Member Author

ktoso commented Apr 24, 2023

@swift-server-bot test this please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant