feat: WithGRPCDialOption for custom gRPC dial settings#23
Open
mlwelles wants to merge 1 commit 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
| base := client{uri: "dgraph://localhost:9080"} | ||
| withOpt := client{uri: "dgraph://localhost:9080"} | ||
| WithGRPCDialOption(grpc.WithUserAgent("x"))(&withOpt.options) | ||
| if base.key() == withOpt.key() { |
There was a problem hiding this comment.
P1: TestKeyDistinguishesGRPCDialOptions only validates 0 vs 1 dial option count, not different values, masking a cache-key collision bug.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At dial_options_test.go, line 27:
<comment>TestKeyDistinguishesGRPCDialOptions only validates 0 vs 1 dial option count, not different values, masking a cache-key collision bug.</comment>
<file context>
@@ -0,0 +1,30 @@
+ base := client{uri: "dgraph://localhost:9080"}
+ withOpt := client{uri: "dgraph://localhost:9080"}
+ WithGRPCDialOption(grpc.WithUserAgent("x"))(&withOpt.options)
+ if base.key() == withOpt.key() {
+ t.Fatal("client.key() must differ when grpcDialOptions differ, else clients dedup incorrectly")
+ }
</file context>
| embeddingKey = fmt.Sprintf("%p", c.options.embeddingProvider) | ||
| } | ||
| return fmt.Sprintf("%s:%t:%d:%d:%d:%d:%s:%s:%s", c.uri, c.options.autoSchema, c.options.poolSize, | ||
| return fmt.Sprintf("%s:%t:%d:%d:%d:%d:%s:%s:%s:%d", c.uri, c.options.autoSchema, c.options.poolSize, |
There was a problem hiding this comment.
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.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At client.go, line 456:
<comment>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.</comment>
<file context>
@@ -430,9 +453,9 @@ func (c client) key() string {
embeddingKey = fmt.Sprintf("%p", c.options.embeddingProvider)
}
- return fmt.Sprintf("%s:%t:%d:%d:%d:%d:%s:%s:%s", c.uri, c.options.autoSchema, c.options.poolSize,
+ return fmt.Sprintf("%s:%t:%d:%d:%d:%d:%s:%s:%s:%d", c.uri, c.options.autoSchema, c.options.poolSize,
c.options.maxEdgeTraversal, c.options.cacheSizeMB, c.options.maxRecvMsgSize,
- c.options.namespace, validatorKey, embeddingKey)
</file context>
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.
Adds
WithGRPCDialOption(opt grpc.DialOption)— a general escape hatch for gRPC dial settings 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.Design
The existing
WithMaxRecvMsgSizeis preserved and folded into the same dial-option assembly, so the two compose rather than conflict —maxRecvMsgSizesimply contributes itsgrpc.WithDefaultCallOptions(...)to the same list. The client dedup cache key now counts the custom dial options, so two clients to the same URI with different dial options are not incorrectly merged.Tests
TestWithGRPCDialOptionAppendsandTestKeyDistinguishesGRPCDialOptionscover the option accumulation and the cache-key disambiguation. Fullgo test -short -race .passes.Summary by cubic
Add
WithGRPCDialOptionto pass customgrpc.DialOptionwhen opening remotedgraph://connections. It composes withWithMaxRecvMsgSize, updates the client dedup key to include dial options, and is ignored for embeddedfile://URIs.Written for commit eee3d01. Summary will update on new commits.