apple / swift-distributed-actors

Peer-to-peer cluster implementation for Swift Distributed Actors
https://apple.github.io/swift-distributed-actors/
Apache License 2.0
587 stars 55 forks source link

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

Open ktoso opened 1 year ago

ktoso commented 1 year ago

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:

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 commented 1 year ago

@swift-server-bot test this please