Skip to content

Commit

Permalink
[Leadership] Deprecate leadership protocol, call it Legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
ktoso committed Apr 24, 2023
1 parent 60502d1 commit 7113d6e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Sources/DistributedCluster/Cluster/Leadership.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ import NIO // Future
/// If a new member is selected as leader, a ``Cluster/Event`` carrying ``Cluster/LeadershipChange`` will be emitted.
/// Other actors may subscribe to `ClusterSystem.cluster.events` in order to receive and react to such changes,
/// e.g. if an actor should only perform its duties if it is residing on the current leader node.
public protocol LeaderElection {
public protocol LegacyLeaderElection {
/// Select a member to become a leader out of the existing `Membership`.
///
/// Decisions about electing/selecting a leader may be performed asynchronously.
mutating func runElection(context: LeaderElectionContext, membership: Cluster.Membership) -> LeaderElectionResult

}

public struct LeaderElectionContext {
Expand Down Expand Up @@ -103,9 +104,9 @@ extension Leadership {
static let naming: _ActorNaming = "leadership"

private var membership: Cluster.Membership // FIXME: we need to ensure the membership is always up to date -- we need the initial snapshot or a diff from a zero state etc.
private var election: LeaderElection
private var election: LegacyLeaderElection

init(_ election: LeaderElection) {
init(_ election: LegacyLeaderElection) {
self.election = election
self.membership = .empty
}
Expand Down Expand Up @@ -227,7 +228,7 @@ extension Leadership {
/// fulfilling this role whenever the minimum number of nodes exist. This may be useful when operation would
/// potentially be unsafe given less than `minimumNrOfMembers` nodes.
///
public struct LowestReachableMember: LeaderElection {
public struct LowestReachableMember: LegacyLeaderElection {
// TODO: In situations which need strong guarantees, this leadership election scheme does NOT provide strong enough
// guarantees, and you should consider using another scheme or consensus based modes.
let minimumNumberOfMembersToDecide: Int
Expand Down Expand Up @@ -331,7 +332,7 @@ extension ClusterSystemSettings {

private let underlying: _LeadershipSelectionSettings

func make(_: ClusterSystemSettings) -> LeaderElection? {
func make(_: ClusterSystemSettings) -> LegacyLeaderElection? {
switch self.underlying {
case .none:
return nil
Expand Down

0 comments on commit 7113d6e

Please sign in to comment.