-
Notifications
You must be signed in to change notification settings - Fork 0
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
Allow handlers to timeout #4
Conversation
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.
Minor things, otherwise looks good.
With
The consequence of this is that a timed-out handler returns
Disconnected
.
you mean we should introduce a different return type?
I think we might want to re-evaluate this and move it into the envelope same as we did here: #5 That might also allow us to more easily return a different type when a handler times out! |
Yes! IMO when you call |
This is momentarily superfluous given that we only have one `Disconnected` variant, but it will make the diff of the next patch cleaner.
ec3f89e
to
2ea9273
Compare
src/address.rs
Outdated
let timed_out_res = rx_timed_out.poll_unpin(ctx); | ||
|
||
match (result_res, timed_out_res) { | ||
(Poll::Ready(Ok(result)), _) => Poll::Ready(Ok(result)), |
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.
Would it be worth it to write out the seconds futures state instead of _
here?
The way how it is written atm is that the first case will match if you have a result
and timeout
. Is that what you want?
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.
It is intentional that the first match arm corresponds to the result future being ready and whatever the result is of the timeout future. I want to always succeed if we have the result of the first channel, even if the second future failed for whatever reason.
For instance, if the second future reports that the timeout has passed but the result is actually ready, we obviously should ignore the timeout and return the result. The timeout is only there as a mechanism to stop handlers that have been running for too long without success.
In practice it may be impossible to ever have a situation where both futures are Poll::Ready(Ok(_))
since we're using future::select
in envelope.rs
. What certainly does happen (consistently) is that the timed_out_channel
is dropped as soon as the result_channel
returns a value. The Drop
implementation of the catty
channel construct actually causes the channel to produce an Err(Disconnected)
. So when we match against the catty::Receiver
s and we have a successful result for the result_channel
, we will have an error for the second one. Which is why we must ignore it for this to work anyway.
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.
Looks good. Nice work
Co-authored-by: Thomas Eizinger <[email protected]>
2ea9273
to
81cb91b
Compare
As a last change, I've added the message name to the |
TODO:
Display
implementation onError
so that we provide more context on the actor and handler that failed.