mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-26 08:56:21 +02:00
Subscriber resilience and RabbitMQ fixes (#765)
Subscriber resilience: recreate consumer after connection failure - Move consumer creation from Subscriber.start() into the run() loop, matching the pattern used by Consumer. If the connection drops and the consumer is closed in the finally block, the loop now recreates it on the next iteration instead of spinning forever on a None consumer. Consumer thread safety: - Dedicated ThreadPoolExecutor per consumer so all pika operations (create, receive, acknowledge, negative_acknowledge) run on the same thread — pika BlockingConnection is not thread-safe - Applies to both Consumer and Subscriber classes Config handler type audit — fix four mismatched type registrations: - librarian: was ["librarian"] (non-existent type), now ["flow", "active-flow"] (matches config["flow"] that the handler reads) - cores/service: was ["kg-core"], now ["flow"] (reads config["flow"]) - metering/counter: was ["token-costs"], now ["token-cost"] (singular) - agent/mcp_tool: was ["mcp-tool"], now ["mcp"] (reads config["mcp"]) Update tests
This commit is contained in:
parent
ddd4bd7790
commit
c20e6540ec
9 changed files with 96 additions and 66 deletions
|
|
@ -81,9 +81,8 @@ class TestTaskGroupConcurrency:
|
|||
|
||||
# Track how many consume_from_queue calls are made
|
||||
call_count = 0
|
||||
original_running = True
|
||||
|
||||
async def mock_consume(backend_consumer):
|
||||
async def mock_consume(backend_consumer, executor=None):
|
||||
nonlocal call_count
|
||||
call_count += 1
|
||||
# Wait a bit to let all tasks start, then signal stop
|
||||
|
|
@ -107,7 +106,7 @@ class TestTaskGroupConcurrency:
|
|||
consumer = _make_consumer(concurrency=1)
|
||||
call_count = 0
|
||||
|
||||
async def mock_consume(backend_consumer):
|
||||
async def mock_consume(backend_consumer, executor=None):
|
||||
nonlocal call_count
|
||||
call_count += 1
|
||||
await asyncio.sleep(0.01)
|
||||
|
|
@ -294,9 +293,8 @@ class TestPollTimeout:
|
|||
raise type('Timeout', (Exception,), {})("timeout")
|
||||
|
||||
mock_pulsar_consumer.receive = capture_receive
|
||||
consumer.consumer = mock_pulsar_consumer
|
||||
|
||||
await consumer.consume_from_queue()
|
||||
await consumer.consume_from_queue(mock_pulsar_consumer)
|
||||
|
||||
assert received_kwargs.get("timeout_millis") == 100
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue