-
Notifications
You must be signed in to change notification settings - Fork 263
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
A way to determine if a Service closed correctly or errored #66
Comments
As a comparison, futures mpsc channel has |
As a part of this change, I think we should explicitly document that poll_ready errors should be considered fatal. If that can't be the case today (i.e. in reconnect), then we may want to figure out if |
Reconnect is an interesting case:
I don't think the proposed change hurts |
Before moving forward with this, I would like to discover a case that is made possible with this change. A service closing normally can be represented with an The original example was a connection pool, where the connection pool needs to know if an inner service failed unexpectedly or closed gracefully. In this example, it is not obvious to me that the connection pool needs to know this. The pool should shield its caller from the details of each individual connection and individual connections may fail without any implication to other connections. So, I would say this should be a "won't fix" until there is a solid use case driving it. |
I'm going to close this as it seems that we are leaning towards "won't fix" |
We can check the status of a
Service
withpoll_ready
, however, that has only 3 states:A
Service
may have closed cleanly, in which case none of those 3 states are correct. The current best choice is to return an error, and hope the error message is sufficient to say it was a clean close. This problem is similar to how before Rust 1.0, aRead
closing would return anErr
ofEof
. Before 1.0, it was changed such that an end-of-file isn't an error, but instead reported asOk(0)
.Some examples of closing cleanly:
We could similarly make closing a clean
Ok
status, instead of an error:As a side note, it'd be really useful at times to be able to check
is_ready
andis_closed
, without being in a task context. For instance, a wrappedService
that returns it to some pool onDrop
could want to check if the underlyingService
is closed. Other cases are to allow forcall
to check if an underlying service is ready even ifpoll_ready
wasn't called previously.The text was updated successfully, but these errors were encountered: