refactor: address PR #851 review round 4 (ingest transport)
- Clear the module-singleton ingest references (task_producer,
document_send_stream, document_receive_stream) on lifespan shutdown via a new
_clear_vector_sync_state() helper, mirroring the eviction_task_group cleanup.
Defense-in-depth so a late webhook (or a module-singleton integration test)
can't touch a producer/stream backed by an already-closed resource.
- Add IngestTransport.backend_name ("memory"/"postgres") and use it in both
lifespan log lines, removing the last settings.ingest_queue read from the
background-sync setup — the lifespan no longer inspects the backend at all.
- Cover backend_name in the build_transport adapter-selection tests.
Refs: Deck #196
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
c0c52c1b34
commit
c4401af9c6
@@ -86,6 +86,15 @@ class IngestTransport(abc.ABC):
|
||||
def producer(self) -> TaskProducer:
|
||||
"""The :class:`TaskProducer` to wire into ``app.state`` / the scanner."""
|
||||
|
||||
@property
|
||||
@abc.abstractmethod
|
||||
def backend_name(self) -> str:
|
||||
"""Short backend identifier for logs/metrics (``memory``/``postgres``).
|
||||
|
||||
Lets the lifespan log which ingest backend is active without reading
|
||||
``settings.ingest_queue`` — the backend choice stays inside the transport.
|
||||
"""
|
||||
|
||||
@property
|
||||
def send_stream(self) -> MemoryObjectSendStream[DocumentTask] | None:
|
||||
"""Memory backend's raw send end; ``None`` for distributed backends.
|
||||
@@ -156,6 +165,10 @@ class LocalTransport(IngestTransport):
|
||||
def producer(self) -> TaskProducer:
|
||||
return self._producer
|
||||
|
||||
@property
|
||||
def backend_name(self) -> str:
|
||||
return "memory"
|
||||
|
||||
@property
|
||||
def send_stream(self) -> MemoryObjectSendStream[DocumentTask]:
|
||||
return self._send_stream
|
||||
@@ -221,6 +234,10 @@ class DistributedTransport(IngestTransport):
|
||||
def producer(self) -> TaskProducer:
|
||||
return self._producer
|
||||
|
||||
@property
|
||||
def backend_name(self) -> str:
|
||||
return "postgres"
|
||||
|
||||
async def aclose(self) -> None:
|
||||
await self._producer.drain()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user