mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
Refactor: Derive consumer behaviour from queue class (#772)
Derive consumer behaviour from queue class, remove consumer_type parameter The queue class prefix (flow, request, response, notify) now fully determines consumer behaviour in both RabbitMQ and Pulsar backends. Added 'notify' class for ephemeral broadcast (config push notifications). Response and notify classes always create per-subscriber auto-delete queues, eliminating orphaned queues that accumulated on service restarts. Change init-trustgraph to set up the 'notify' namespace in Pulsar instead of old hangover 'state'. Fixes 'stuck backlog' on RabbitMQ config notification queue.
This commit is contained in:
parent
aff96e57cb
commit
feeb92b33f
15 changed files with 93 additions and 95 deletions
|
|
@ -151,7 +151,7 @@ class TestConfigReceiver:
|
|||
mock_backend = Mock()
|
||||
config_receiver = ConfigReceiver(mock_backend)
|
||||
|
||||
# Mock config_client
|
||||
# Mock _create_config_client to return a mock client
|
||||
mock_resp = Mock()
|
||||
mock_resp.error = None
|
||||
mock_resp.version = 5
|
||||
|
|
@ -164,7 +164,7 @@ class TestConfigReceiver:
|
|||
|
||||
mock_client = AsyncMock()
|
||||
mock_client.request.return_value = mock_resp
|
||||
config_receiver.config_client = mock_client
|
||||
config_receiver._create_config_client = Mock(return_value=mock_client)
|
||||
|
||||
start_flow_calls = []
|
||||
async def mock_start_flow(id, flow):
|
||||
|
|
@ -202,7 +202,7 @@ class TestConfigReceiver:
|
|||
|
||||
mock_client = AsyncMock()
|
||||
mock_client.request.return_value = mock_resp
|
||||
config_receiver.config_client = mock_client
|
||||
config_receiver._create_config_client = Mock(return_value=mock_client)
|
||||
|
||||
stop_flow_calls = []
|
||||
async def mock_stop_flow(id, flow):
|
||||
|
|
@ -229,7 +229,7 @@ class TestConfigReceiver:
|
|||
|
||||
mock_client = AsyncMock()
|
||||
mock_client.request.return_value = mock_resp
|
||||
config_receiver.config_client = mock_client
|
||||
config_receiver._create_config_client = Mock(return_value=mock_client)
|
||||
|
||||
await config_receiver.fetch_and_apply()
|
||||
|
||||
|
|
@ -353,7 +353,7 @@ class TestConfigReceiver:
|
|||
|
||||
mock_client = AsyncMock()
|
||||
mock_client.request.return_value = mock_resp
|
||||
config_receiver.config_client = mock_client
|
||||
config_receiver._create_config_client = Mock(return_value=mock_client)
|
||||
|
||||
start_calls = []
|
||||
stop_calls = []
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ class TestQueueFunction:
|
|||
def test_response_class(self):
|
||||
assert queue('config', cls='response') == 'response:tg:config'
|
||||
|
||||
def test_state_class(self):
|
||||
assert queue('config', cls='state') == 'state:tg:config'
|
||||
def test_notify_class(self):
|
||||
assert queue('config', cls='notify') == 'notify:tg:config'
|
||||
|
||||
def test_custom_topicspace(self):
|
||||
assert queue('config', cls='request', topicspace='prod') == 'request:prod:config'
|
||||
|
|
@ -44,9 +44,9 @@ class TestPulsarMapTopic:
|
|||
assert backend.map_topic('flow:tg:text-completion-request') == \
|
||||
'persistent://tg/flow/text-completion-request'
|
||||
|
||||
def test_state_maps_to_persistent(self, backend):
|
||||
assert backend.map_topic('state:tg:config') == \
|
||||
'persistent://tg/state/config'
|
||||
def test_notify_maps_to_non_persistent(self, backend):
|
||||
assert backend.map_topic('notify:tg:config') == \
|
||||
'non-persistent://tg/notify/config'
|
||||
|
||||
def test_request_maps_to_non_persistent(self, backend):
|
||||
assert backend.map_topic('request:tg:config') == \
|
||||
|
|
@ -153,7 +153,7 @@ class TestQueueDefinitions:
|
|||
|
||||
def test_config_push(self):
|
||||
from trustgraph.schema.services.config import config_push_queue
|
||||
assert config_push_queue == 'flow:tg:config'
|
||||
assert config_push_queue == 'notify:tg:config'
|
||||
|
||||
def test_librarian_request(self):
|
||||
from trustgraph.schema.services.library import librarian_request_queue
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ class TestRabbitMQMapQueueName:
|
|||
assert durable is True
|
||||
assert name == 'tg.flow.text-completion-request'
|
||||
|
||||
def test_state_is_durable(self, backend):
|
||||
name, durable = backend.map_queue_name('state:tg:config')
|
||||
assert durable is True
|
||||
assert name == 'tg.state.config'
|
||||
def test_notify_is_not_durable(self, backend):
|
||||
name, durable = backend.map_queue_name('notify:tg:config')
|
||||
assert durable is False
|
||||
assert name == 'tg.notify.config'
|
||||
|
||||
def test_request_is_not_durable(self, backend):
|
||||
name, durable = backend.map_queue_name('request:tg:config')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue