feat: WithGRPCDialOption for custom gRPC dial settings#23
Open
mlwelles wants to merge 2 commits into
Open
Conversation
Adds WithGRPCDialOption(opt grpc.DialOption), a general escape hatch for gRPC dial settings the dedicated options do not cover — TLS transport credentials, interceptors, keepalive, and so on — on remote (dgraph://) connections. The existing WithMaxRecvMsgSize is folded into the same dial-option assembly, so the two compose cleanly, and the client dedup key now counts the custom dial options so differently-configured clients are not merged. No change for embedded (file://) URIs.
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="dial_options_test.go">
<violation number="1" location="dial_options_test.go:27">
P1: TestKeyDistinguishesGRPCDialOptions only validates 0 vs 1 dial option count, not different values, masking a cache-key collision bug.</violation>
</file>
<file name="client.go">
<violation number="1" location="client.go:456">
P1: Cache key disambiguation for custom gRPC dial options is lossy (count-only), allowing collisions for different options and inconsistent behavior with documented embedded-mode ignore semantics.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Addresses review feedback on WithGRPCDialOption: - client.key() keyed custom gRPC dial options by count only, so two clients to the same URI with one different option each produced the same key and were merged in the dedup cache. The key now includes each option's runtime identity (grpc.DialOption is opaque and not comparable), so differently configured clients are never merged. The cache errs toward keeping clients apart rather than merging connections configured differently. - Dial options apply only to remote (dgraph://) connections, so they now contribute to the key only for remote URIs — consistent with the documented "ignored for file://" behavior. Tests: - TestKeyDistinguishesGRPCDialOptions now also asserts two clients with the same option count but different options get different keys. - TestKeyIgnoresGRPCDialOptionsForEmbedded asserts dial options do not affect the key for embedded (file://) clients. Docs: add a runnable ExampleWithGRPCDialOption (TLS credentials + keepalive).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
WithGRPCDialOption(opt grpc.DialOption)— a general escape hatch for gRPC dialsettings the dedicated options do not cover: TLS transport credentials,
interceptors, keepalive parameters, and so on. Applied when opening a remote
(
dgraph://) connection; ignored for embedded (file://) URIs.The problem it solves
The client exposed only a fixed set of gRPC knobs (e.g.
WithMaxRecvMsgSize).Anything else — mTLS, auth interceptors, custom keepalive — required forking the
connection code.
WithGRPCDialOptionlets callers pass anygrpc.DialOptionstraight through to the dial, so the client covers the long tail of gRPC
configuration without growing a dedicated option for each.
WithMaxRecvMsgSizeis preserved and folded into the same dial-option assembly,so the two compose rather than conflict.
Review round — changes since first push
Addresses the automated review (cubic):
(
len(...)), so two clients to the same URI with one different option eachproduced the same key and were incorrectly merged.
grpc.DialOptionvaluesare opaque and not comparable, so the key now includes each option's runtime
identity. Differently configured clients are never merged; the cache errs
toward keeping them apart.
remote (
dgraph://) URIs, matching the documented "ignored forfile://"behavior.
now asserts that two clients with the same count but different options get
different keys.
Tests
TestKeyDistinguishesGRPCDialOptions— different options at the same countyield different keys.
TestKeyIgnoresGRPCDialOptionsForEmbedded— dial options do not affect thekey for
file://clients.TestWithGRPCDialOptionAppends— options accumulate.Documentation
A runnable
ExampleWithGRPCDialOptionshowing TLS credentials and keepalive.