RDDT: Separate connection policy and construction - #34
Open
cshoe wants to merge 1 commit into
Open
Conversation
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>
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.
💸 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
✅ Checks