You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This mirrors the Service trait while including two additional functions: poll_service and poll_close.
Currently, poll_service is documented as:
Returns Ready whenever there is no more work to be done until call
is invoked again.
Note that this method may return NotReady even if there are no
outstanding requests, if the service has to perform non-request-driven
operations (e.g., heartbeats).
Proposal
Most services, including HTTP 1.0 services, need a way to signal graceful close. poll_service should be updated such that Ready is returned when the service has gracefully closed without the user requesting a close by calling poll_close.
Implementations of DirectService should make a best effort to return Ready from poll_service when the service is closed. However, there is no guarantee that poll_service will return Ready before a call to poll_ready returning an error due to the service being closed. It is sometimes impossible to detect the service being closed without attempting to check for readiness.
This also would allow for a class of middleware that are able to "ignore" inner service errors by mapping service errors to a graceful close. This would be useful for middleware like ConnectionPool, which needs to be able to tell the difference between a fatal inner service error and an inner service gracefully going away.
This issue proposes to change the contract of the
poll_service
function onDirectService
Background
The current implementation of
DirectService
is as follows:This mirrors the
Service
trait while including two additional functions:poll_service
andpoll_close
.Currently,
poll_service
is documented as:Proposal
Most services, including HTTP 1.0 services, need a way to signal graceful close.
poll_service
should be updated such thatReady
is returned when the service has gracefully closed without the user requesting a close by callingpoll_close
.Implementations of
DirectService
should make a best effort to returnReady
frompoll_service
when the service is closed. However, there is no guarantee thatpoll_service
will returnReady
before a call topoll_ready
returning an error due to the service being closed. It is sometimes impossible to detect the service being closed without attempting to check for readiness.This also would allow for a class of middleware that are able to "ignore" inner service errors by mapping service errors to a graceful close. This would be useful for middleware like
ConnectionPool
, which needs to be able to tell the difference between a fatal inner service error and an inner service gracefully going away.Refs #136
cc/ @jonhoo @seanmonstar
The text was updated successfully, but these errors were encountered: