-
Notifications
You must be signed in to change notification settings - Fork 78
=fix #614 fix deathwatch parent/child guard, ensure single terminated; fix interceptor test #763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…; fix interceptor test via this
| with terminationMessage: Message? = nil, | ||
| file: String = #file, line: UInt = #line | ||
| ) -> Watchee where Watchee: DeathWatchable { | ||
| self.deathWatch.watch(watchee: watchee, with: terminationMessage, myself: self.myself, parent: self._parent, file: file, line: line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- the parent is super unnecessary for ISSUING a watch;
- we don't care about OUR parent, only if we are the parent of the being watched actor, as such we can pass
myself(selfin order to have_childrento check them inside there)
- we don't care about OUR parent, only if we are the parent of the being watched actor, as such we can pass
- it optionally necessary for HANDLING a watch.
- it's not required, but we're being defensive now, even if someone sent us such system message we'd do the right thing
| try postStop(context) | ||
| } | ||
| return .same // will be ignored | ||
| return .stop // will be ignored |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just cosmetic tbh
|
|
||
| /// Performed by the sending side of "watch", therefore the `watcher` should equal `context.myself` | ||
| public mutating func watch<Watchee>( | ||
| mutating func watch<Watchee>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does not have to be public
| return | ||
| } | ||
|
|
||
| guard addressableWatchee.address != parent.address else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whooop! this is in the wrong function, moved to becomeWatchedBy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙀
| // not yet watching, so let's add it: | ||
| self.watching[addressableWatchee] = OnTerminationMessage(customize: terminationMessage) | ||
|
|
||
| if !watcher.children.contains(identifiedBy: watchee.asAddressable.address) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we proactively avoid sending a message which would have been ignored anyway
| /// and our direct message arrives first, before the watch at the destination, causing potentially confusing behavior | ||
| /// in some very ordering delicate testing scenarios. | ||
| public func forward<Message>(_ message: Message, to target: ActorRef<Message>, file: String = #file, line: UInt = #line) where Message: Codable { | ||
| self.internalRef.tell(ProbeCommands.forwardCommand(send: { () in target.tell(message, file: file, line: line) })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really necessary here, since watching a dead actor works as well, but I wanted to make sure to see the exact ordering I'm testing.
| terminated.address.path.shouldEqual(try! ActorPath._user.appending("parent").appending("stopper")) | ||
| terminated.existenceConfirmed.shouldBeTrue() | ||
| terminated.nodeTerminated.shouldBeFalse() | ||
| terminated.shouldBe(Signals.ChildTerminated.self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which would have potentially failed and may have received Terminated before (!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(or rather, the expect no message would have gotten it)
| let terminated = try p.expectMessage() | ||
| (terminated.address.name == "stopperOne" || terminated.address.name == "stopperTwo").shouldBeTrue() | ||
| try p.expectNoMessage(for: .milliseconds(100)) | ||
| try p.expectNoMessage(for: .milliseconds(500)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be extra sure
| } | ||
|
|
||
| func test_interceptor_shouldRemainWHenReturningStoppingWithPostStop() throws { | ||
| func test_interceptor_shouldRemainWhenReturningStoppingWithPostStop() throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was a typo
yim-lee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find!
| return | ||
| } | ||
|
|
||
| guard addressableWatchee.address != parent.address else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙀
Motivation:
Result:
ChildTerminated)