Skip to content

Conversation

@dnephin
Copy link
Member

@dnephin dnephin commented Jan 9, 2026

💸 TL;DR

We'd like to support non-blocking dials in dev, even if the service is configured to use grpc.WithBlock in production.

📜 Details

This PR adds a new DialOption that can be used instead of grpc.WithBlock. When the dial option is used, and the REDDIT_RPC_CONNECTION_MODE=non-blocking env 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 set WaitForReady(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

  • CI tests (if present) are passing
  • Adheres to code style for repo
  • Contributor License Agreement (CLA) completed if not a Reddit employee

@dnephin dnephin requested a review from a team as a code owner January 9, 2026 16:50
@dnephin dnephin requested review from konradreiche, mathyourlife-reddit and pacejackson and removed request for a team January 9, 2026 16:50
@dnephin dnephin force-pushed the dnephin/with-default-block branch from c1f055b to e2f7bc9 Compare January 9, 2026 16:53
// 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(
Copy link
Contributor

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?

Copy link
Member Author

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!

@dnephin
Copy link
Member Author

dnephin commented Jan 12, 2026

I'm going to move this to a different repo

@dnephin dnephin closed this Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants