Conversation
akbashev
left a comment
There was a problem hiding this comment.
Some small comments from my side.
imho should be merged even in the form of PoC, benefits are big and we can figure out later on how to improve.
| } | ||
|
|
||
| print("Sleeping...") | ||
| _Thread.sleep(duration) |
There was a problem hiding this comment.
Guess if there is a plan to update repo, we can stop using _Thread and use Task.sleep(for:) instead already?
| guard let target = self.gossipPeers.shuffled().first else { | ||
| log.info("No peer to gossip with...") | ||
| return | ||
| } | ||
|
|
||
| guard target.id != self.id else { | ||
| return try await gossipRound() // try again | ||
| } |
There was a problem hiding this comment.
Maybe missing something, but a bit confusing guard, like why not to filter for id in set?
| } | ||
|
|
||
| guard target.id != self.id else { | ||
| return try await gossipRound() // try again |
There was a problem hiding this comment.
Also while testing and while cluster is forming this function goes in loop heavily 🤔 maybe adding something like:
| return try await gossipRound() // try again | |
| if self.gossipPeers.count == 1 { | |
| try await Task.sleep(for: .seconds(0.1)) | |
| } | |
| return try await gossipRound() // try again |
| // distributed func acknowledgement(_ acknowledgement: Acknowledgement, | ||
| // from peer: ID, | ||
| // confirming gossip: Gossip) { | ||
| // | ||
| // } |
There was a problem hiding this comment.
Is it needed? Not like nitpicking, but rather thinking about future refactoring—I've noticed there are some commented code here and there (not much though) and sometimes not sure if I should just remove it or not.
| // FIXME(distributed): remove [#957](https://github.com/apple/swift-distributed-actors/issues/957) | ||
| enum InvocationBehavior { | ||
| static func behavior(instance weakInstance: Weak<some DistributedActor>) -> _Behavior<InvocationMessage> { | ||
| static func behavior(instance weakInstance: WeakLocalRef<some DistributedActor>) -> _Behavior<InvocationMessage> { |
There was a problem hiding this comment.
Wonder if we can just remove WeakLocalRef here and just check for weak in closures bellow.
| enum _Strategy { | ||
| case random | ||
| case simpleRoundRobin | ||
| } |
Second commit here shows off how we can implement a simple gossip mechanism.
This is just a quick PoC not a complete implementation and implemented as a sample rather than the core of the library for now, but we should move that over.