-
Notifications
You must be signed in to change notification settings - Fork 86
grpcbp: support conditional non-blocking mode #708
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
c1f055b to
e2f7bc9
Compare
Co-authored-by: Konrad Reiche <[email protected]>
| // added to improve connection error messages and to set [grpc.WaitForReady] on all RPC calls. | ||
| func WithDefaultBlock() grpc.DialOption { | ||
| if strings.EqualFold(os.Getenv("REDDIT_RPC_CONNECTION_MODE"), "non-blocking") { | ||
| return grpc.WithChainUnaryInterceptor( |
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.
what about stream connections? would grpc.WithDefaultCallOptions(grpc.WaitForReady(true)) provide what you're looking for?
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 sure how to handle streaming connections. We'll have to revisit streaming connections later if we find some that are relevant.
WithDefaultCallOptions does seem like a better way to implement this!
|
I'm going to move this to a different repo |
💸 TL;DR
We'd like to support non-blocking dials in dev, even if the service is configured to use
grpc.WithBlockin production.📜 Details
This PR adds a new
DialOptionthat can be used instead ofgrpc.WithBlock. When the dial option is used, and theREDDIT_RPC_CONNECTION_MODE=non-blockingenv var is set the dial will be non-blocking , and two interceptors will be added. The interceptors improve the connection error message by adding the hostname (similar to #707) and setWaitForReady(true)on all RPC requests. This way a request waits for a connection the full context timeout (instead of failing fast immediately if there is no connection).🧪 Testing Steps / Validation
Test added in this PR.
✅ Checks