Skip to content

feat(client): opt-in connection check on Qdrant::build()#286

Merged
timvisee merged 3 commits into
qdrant:devfrom
ameyypawar:fix/258-check-connection
Jul 1, 2026
Merged

feat(client): opt-in connection check on Qdrant::build()#286
timvisee merged 3 commits into
qdrant:devfrom
ameyypawar:fix/258-check-connection

Conversation

@ameyypawar

Copy link
Copy Markdown

Fixes #258.

Problem

gRPC connections are established lazily, so Qdrant::build() returns Ok even 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_connection flag on QdrantConfig:

let client = Qdrant::from_url("http://localhost:6334")
    .check_connection()
    .build()?; // returns Err if the server can't be reached
  • New check_connection: bool field (default false), a check_connection() builder method, and a set_check_connection() setter.
  • Qdrant::new reuses the existing health-check path; when check_connection is set, the health-check error is returned instead of swallowed.
  • Default behavior is unchanged — with the flag unset, build() stays lazy exactly as before, so this is non-breaking.

Tests

Two server-free unit tests (connection refused on a closed local port):

  • default build succeeds when the server is down (the lazy path), and
  • 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 — clean
  • cargo clippy --workspace --all-targets --all-features -- -D warnings — clean
  • cargo test --lib --all-features — passes (the 3 failing tests require a running Qdrant instance on :6334 and 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 on build(), 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

New Feature Submissions

  1. Does your submission pass tests?
  2. Have you formatted your code with rustfmt?
  3. Have you checked your code with cargo clippy --all --all-features?

Changes to Core Features

  • Added an explanation of what the change does and why.
  • Added new tests for the change.
  • Ran tests locally.

ameyypawar and others added 3 commits June 30, 2026 22:50
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 timvisee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! I like the way this is implemented.

@timvisee timvisee merged commit 35c1e47 into qdrant:dev Jul 1, 2026
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.

2 participants