feat(client): opt-in connection check on Qdrant::build()#286
Merged
Conversation
gRPC connections are established lazily, so `Qdrant::build()` returns `Ok` even when the server is unreachable; connection errors only surface on the first API call. The default compatibility check already performs a health check on build, but silently discards connection failures. Add an opt-in `check_connection` config flag with a `check_connection()` builder method and a `set_check_connection()` setter. When enabled, `build()` reuses the existing health-check path and returns the error eagerly instead of deferring it. Default behavior is unchanged. Add server-free unit tests for both the lazy (default) and eager (opt-in) build paths. The CI workflow that runs them was added in the preceding commit.
The existing Test workflow already runs `cargo test --all` via integration-tests.sh, which covers the new unit tests. Revert the accidental change to this file.
timvisee
approved these changes
Jul 1, 2026
timvisee
left a comment
Member
There was a problem hiding this comment.
Thanks! I like the way this is implemented.
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.
Fixes #258.
Problem
gRPC connections are established lazily, so
Qdrant::build()returnsOkeven when the server is unreachable — a connection failure only surfaces on the first API call.build()already runs a health check for the default compatibility check, but a connection error there is silently discarded (.ok()), so there is no way to detect an unreachable server up front.Change
Adds an opt-in
check_connectionflag onQdrantConfig:check_connection: boolfield (defaultfalse), acheck_connection()builder method, and aset_check_connection()setter.Qdrant::newreuses the existing health-check path; whencheck_connectionis set, the health-check error is returned instead of swallowed.build()stays lazy exactly as before, so this is non-breaking.Tests
Two server-free unit tests (connection refused on a closed local port):
check_connection()build fails eagerly when the server is down.These run under the existing
test.yml(cargo test --all); no new workflow is added.Verification
cargo fmt --all -- --check— cleancargo clippy --workspace --all-targets --all-features -- -D warnings— cleancargo test --lib --all-features— passes (the 3 failing tests require a running Qdrant instance on:6334and are unrelated to this change)Note on #259
#259 also targets #258, via a separate
connect()method. This PR instead makes the check opt-in onbuild(), reusing the existing health-check machinery without adding a new public method beyond the config toggle. Happy to align with whichever direction you prefer.All Submissions
devbranch.New Feature Submissions
cargo clippy --all --all-features?Changes to Core Features