Skip to content

feat: WithGRPCDialOption for custom gRPC dial settings#23

Open
mlwelles wants to merge 1 commit into
matthewmcneely:mainfrom
mlwelles:feature/grpc-dial-options
Open

feat: WithGRPCDialOption for custom gRPC dial settings#23
mlwelles wants to merge 1 commit into
matthewmcneely:mainfrom
mlwelles:feature/grpc-dial-options

Conversation

@mlwelles

@mlwelles mlwelles commented Jun 4, 2026

Copy link
Copy Markdown

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 WithMaxRecvMsgSize is preserved and folded into the same dial-option assembly, so the two compose rather than conflict — maxRecvMsgSize simply contributes its grpc.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

TestWithGRPCDialOptionAppends and TestKeyDistinguishesGRPCDialOptions cover the option accumulation and the cache-key disambiguation. Full go test -short -race . passes.


Summary by cubic

Add WithGRPCDialOption to pass custom grpc.DialOption when opening remote dgraph:// connections. It composes with WithMaxRecvMsgSize, updates the client dedup key to include dial options, and is ignored for embedded file:// URIs.

Written for commit eee3d01. Summary will update on new commits.

Review in cubic

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.
@mlwelles mlwelles requested a review from matthewmcneely as a code owner June 4, 2026 20:06

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread dial_options_test.go
base := client{uri: "dgraph://localhost:9080"}
withOpt := client{uri: "dgraph://localhost:9080"}
WithGRPCDialOption(grpc.WithUserAgent("x"))(&withOpt.options)
if base.key() == withOpt.key() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Comment thread client.go
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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant