Skip to content

Commit 7113d6e

Browse files
committed
[Leadership] Deprecate leadership protocol, call it Legacy
1 parent 60502d1 commit 7113d6e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Sources/DistributedCluster/Cluster/Leadership.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ import NIO // Future
4242
/// If a new member is selected as leader, a ``Cluster/Event`` carrying ``Cluster/LeadershipChange`` will be emitted.
4343
/// Other actors may subscribe to `ClusterSystem.cluster.events` in order to receive and react to such changes,
4444
/// e.g. if an actor should only perform its duties if it is residing on the current leader node.
45-
public protocol LeaderElection {
45+
public protocol LegacyLeaderElection {
4646
/// Select a member to become a leader out of the existing `Membership`.
4747
///
4848
/// Decisions about electing/selecting a leader may be performed asynchronously.
4949
mutating func runElection(context: LeaderElectionContext, membership: Cluster.Membership) -> LeaderElectionResult
50+
5051
}
5152

5253
public struct LeaderElectionContext {
@@ -103,9 +104,9 @@ extension Leadership {
103104
static let naming: _ActorNaming = "leadership"
104105

105106
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.
106-
private var election: LeaderElection
107+
private var election: LegacyLeaderElection
107108

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

332333
private let underlying: _LeadershipSelectionSettings
333334

334-
func make(_: ClusterSystemSettings) -> LeaderElection? {
335+
func make(_: ClusterSystemSettings) -> LegacyLeaderElection? {
335336
switch self.underlying {
336337
case .none:
337338
return nil

0 commit comments

Comments
 (0)