perf: switch Qdrant to AsyncQdrantClient with explicit timeout

Every vector call ran on the sync QdrantClient inside async wrapper
methods, blocking the FastAPI event loop per Qdrant round-trip. The
wrapper now holds an AsyncQdrantClient (timeout via QDRANT_TIMEOUT,
default 30s) and awaits all client calls; the wrapper API is unchanged.

Call sites off the wrapper were fixed too: the HybridRAG document leg
now uses the async search_vectors wrapper instead of the deprecated raw
client.search (also fixing its call to the nonexistent ollama.embed_text
which made the leg permanently report 'failed'), the health check awaits
get_collections, and document_sync's raw delete/upsert calls are awaited
(routed through wrappers in the next commit).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QbFZyDvYksazX6nYQYZ67L
This commit is contained in:
2026-07-14 12:58:01 +02:00
co-authored by Claude Fable 5
parent 0b346d3a57
commit 406143e7ae
8 changed files with 53 additions and 48 deletions
+1 -1
View File
@@ -148,7 +148,7 @@ class TestQdrantIntegration:
collection_name = qdrant_client.get_collection_name(test_user)
await qdrant_client.ensure_collection(collection_name)
collections = qdrant_client.client.get_collections()
collections = await qdrant_client.client.get_collections()
collection_names = [c.name for c in collections.collections]
assert collection_name in collection_names
+5 -3
View File
@@ -42,8 +42,6 @@ def mock_qdrant():
qdrant.search_with_expiry_filter = AsyncMock(return_value=[])
qdrant.upsert_vector = AsyncMock(return_value=True)
qdrant.delete_by_filter = AsyncMock(return_value=0)
qdrant.client = MagicMock()
qdrant.client.search = MagicMock(return_value=[])
return qdrant
@@ -307,9 +305,13 @@ class TestDocumentLegScoping:
await hybrid_service._retrieve_parallel("q", TENANT, config, {})
assert (
mock_qdrant.client.search.call_args.kwargs["collection_name"]
mock_qdrant.search_vectors.await_args.kwargs["collection_name"]
== TENANT_COLLECTION
)
assert (
mock_qdrant.search_vectors.await_args.kwargs["filter_conditions"]
== {"doc_type": "document"}
)
# =============================================================================