Skip to content

RDDT: Separate connection policy and construction - #34

Open
cshoe wants to merge 1 commit into
masterfrom
separate-conn-policy-and-construction
Open

RDDT: Separate connection policy and construction#34
cshoe wants to merge 1 commit into
masterfrom
separate-conn-policy-and-construction

Conversation

@cshoe

@cshoe cshoe commented Aug 18, 2026

Copy link
Copy Markdown

💸 TL;DR

These changes separate Milvus connection policy from connection creation by introducing a factory boundary that lets the SDK describe its required transport settings and interceptors without owning the dial itself. This design also provides flexibility to evolve connection behavior or use alternative connection factories without coupling those decisions to the Milvus SDK.

📜 Details

Milvus previously assembled grpc.DialOptions and called grpc.DialContext directly. That made it impossible for a downstream integration to create the channel through a platform gRPC library whose observability, adaptive throttling, resolver behavior, and middleware policy are installed as part of its own dial operation rather than exposed as ordinary grpc.DialOptions.

Add an optional ConnectionFactory to ClientConfig so connection construction can occur outside the Milvus library. The factory receives the resolved target and a ConnectionOptions value containing effective transport credentials, explicitly configured DialOptions, and Milvus unary and stream interceptors. This lets an external dialer translate each part into its supported APIs while preserving Milvus authentication and database metadata. Milvus continues to own and close the returned connection and initializes its service clients exactly as before.

Keep the factory boundary intentionally small: ConnectionOptions exposes one DialOptions slice containing only caller-provided options. The built-in factory continues to apply DefaultGrpcOpts before that slice, while an external factory owns its own default connection policy. This avoids requiring alternate dialers to inspect opaque grpc.DialOption values or distinguish SDK policy from caller intent.

Make the existing transport retry attempt limit configurable through RetryTransportOption. A nil option preserves the existing six-attempt policy for Unavailable and ResourceExhausted responses, a positive value selects another limit, and zero omits the retry interceptor. This allows an external connection stack to own retry policy and coordinate it with admission control without forcing existing clients to change.

The extension is opt-in. When ConnectionFactory is nil, the built-in path still calls grpc.DialContext with transport credentials, Milvus defaults, caller options, transport retry, and the metadata interceptor in the same effective order. Existing TLS selection, default retry count and backoff, metadata propagation, initial Milvus Connect behavior, service construction, and connection ownership remain unchanged.

Add coverage for custom connection construction, caller option forwarding, the preserved default retry count, configurable and disabled retries, retryable status codes, and non-retryable failures.

🧪 Testing Steps / Validation

  • Tests were added to ensure current functionality remains unchanged
  • Tests targeting the new features were added

✅ Checks

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

Milvus previously assembled grpc.DialOptions and called grpc.DialContext directly. That made it impossible for a downstream integration to create the channel through a platform gRPC library whose observability, adaptive throttling, resolver behavior, and middleware policy are installed as part of its own dial operation rather than exposed as ordinary grpc.DialOptions.

Add an optional ConnectionFactory to ClientConfig so connection construction can occur outside the Milvus library. The factory receives the resolved target and a ConnectionOptions value containing effective transport credentials, explicitly configured DialOptions, and Milvus unary and stream interceptors. This lets an external dialer translate each part into its supported APIs while preserving Milvus authentication and database metadata. Milvus continues to own and close the returned connection and initializes its service clients exactly as before.

Keep the factory boundary intentionally small: ConnectionOptions exposes one DialOptions slice containing only caller-provided options. The built-in factory continues to apply DefaultGrpcOpts before that slice, while an external factory owns its own default connection policy. This avoids requiring alternate dialers to inspect opaque grpc.DialOption values or distinguish SDK policy from caller intent.

Make the existing transport retry attempt limit configurable through RetryTransportOption. A nil option preserves the existing six-attempt policy for Unavailable and ResourceExhausted responses, a positive value selects another limit, and zero omits the retry interceptor. This allows an external connection stack to own retry policy and coordinate it with admission control without forcing existing clients to change.

The extension is opt-in. When ConnectionFactory is nil, the built-in path still calls grpc.DialContext with transport credentials, Milvus defaults, caller options, transport retry, and the metadata interceptor in the same effective order. Existing TLS selection, default retry count and backoff, metadata propagation, initial Milvus Connect behavior, service construction, and connection ownership remain unchanged.

Add coverage for custom connection construction, caller option forwarding, the preserved default retry count, configurable and disabled retries, retryable status codes, and non-retryable failures.

Signed-off-by: Chris Schomaker <chris.schomaker@reddit.com>
@cshoe
cshoe requested a review from c-i-njoroge August 18, 2026 16:28
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.

1 participant