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
Require poll_ready
to be called before call
#161
Conversation
This updates the `Service` contract requiring `poll_ready` to be called before `call`. This allows `Service::call` to panic in the event the user of the service omits `poll_ready` or does not wait until `Ready` is observed.
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.
I'm 👍 for this change, it does seem to simplify a lot of the impls.
I think Lines 192 to 200 in 25eb521
|
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.
I'm not so convinced that panicking so easily is the right call.
What's the motivation, to remove some error variants? There is still code in place to branch to panic, so the branches aren't less there. If we change to #156, then the user doesn't need to see the NotReady
variant.
The motivation is to have more defined contract for the With this change, the contract is clearer: you must always get panic vs. Also, I much prefer panics when there is a bug because you get a backtrace! If Ideally, the panic is isolated to the task that is handling the request and does not impact unrelated tasks in the process. I prefer to use reserve Also, while the |
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.
I agree with "panic on programmer error", my reservation was that I thought the buffer instance could panic even if the programmer didn't do anything wrong. 👍
This updates the
Service
contract requiringpoll_ready
to be calledbefore
call
. This allowsService::call
to panic in the event theuser of the service omits
poll_ready
or does not wait untilReady
isobserved.