Skip to content

Commit 21e230c

Browse files
committed
+docs some docs for leadership
1 parent 5b3a4d6 commit 21e230c

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

Sources/DistributedActors/Cluster/Leadership.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ extension Leadership {
223223
/// fulfilling this role whenever the minimum number of nodes exist. This may be useful when operation would
224224
/// potentially be unsafe given less than `minimumNrOfMembers` nodes.
225225
///
226-
// TODO: In situations which need strong guarantees, this leadership election scheme does NOT provide strong enough
227-
/// guarantees, and you should consider using another scheme or consensus based modes.
228226
public struct LowestReachableMember: LeaderElection {
227+
// TODO: In situations which need strong guarantees, this leadership election scheme does NOT provide strong enough
228+
// guarantees, and you should consider using another scheme or consensus based modes.
229229
let minimumNumberOfMembersToDecide: Int
230230
let loseLeadershipIfBelowMinNrOfMembers: Bool
231231

@@ -318,6 +318,7 @@ extension Leadership {
318318
// MARK: Leadership settings
319319

320320
extension ClusterSystemSettings {
321+
/// Configure leadership election using which the cluster leader should be decided.
321322
public struct LeadershipSelectionSettings {
322323
private enum _LeadershipSelectionSettings {
323324
case none

Sources/DistributedActors/Docs.docc/Clustering.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,14 @@ The ``Cluster/Membership`` also offers a number of useful APIs to inspect the me
180180
181181
## Cluster Leadership
182182

183-
TODO: document leadership and Leadership changes.
183+
The cluster has a few operations which must be performed in a consistent fashion, such as moving a joining member to the ``Cluster/MemberStatus/up`` state. Other member status changes such as becoming `joining` or `down` do not require such strict decision-making and are disseminated throughout the cluster even without a leader.
184+
185+
Which cluster member is designated a leader is decided by the configured ``LeaderElection`` strategy.
186+
187+
By default, the leader is selected in a coordination free method which relies on the membership state and member ordering.
188+
For details, refer to the ``Leadership/LowestReachableMember`` documentation.
189+
190+
You can configure leader election by changing the ``ClusterSystemSettings/autoLeaderElection`` setting while initializing your ``ClusterSystem``.
184191

185192
## Customizing Remote Calls
186193

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ``DistributedActors/ClusterSystemSettings/LeadershipSelectionSettings``
2+
3+
@Metadata {
4+
@DocumentationExtension(mergeBehavior: append)
5+
}
6+
7+
## Topics
8+
9+
### Pre-defined leadership election strategies
10+
11+
- ``lowestReachable(minNumberOfMembers:)``
12+
- ``none``

0 commit comments

Comments
 (0)