chatgraph 1.2.3__tar.gz → 1.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {chatgraph-1.2.3 → chatgraph-1.2.4}/PKG-INFO +1 -1
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/messages/message_consumer.py +12 -2
- {chatgraph-1.2.3 → chatgraph-1.2.4}/pyproject.toml +1 -1
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/unit/test_message_consumer.py +40 -1
- {chatgraph-1.2.3 → chatgraph-1.2.4}/.env.example +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/.github/agents/SkillManager.agent.md +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/.github/agents/architect.agent.md +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/.github/agents/code-reviewer.agent.md +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/.github/agents/developer.agent.md +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/.github/copilot-instructions.md +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/.github/skills/chatgraph-framework/SKILL.md +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/.gitignore +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/.python-version +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/LICENSE +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/README.md +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/__init__.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/auth/credentials.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/bot/chatbot_model.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/bot/chatbot_router.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/bot/default_functions.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/bot/default_guard.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/cli/__init__.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/container/container.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/error/chatbot_error.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/error/route_error.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/gRPC/gRPCCall.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/logger/__init__.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/logger/logger.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/logger/user_logger.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/models/actions.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/models/http_responses.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/models/message.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/models/userstate.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/pb/router.proto +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/pb/router_pb2.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/pb/router_pb2_grpc.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/services/__init__.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/services/router_http_client.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/types/background_task.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/types/end_types.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/types/route.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/chatgraph/types/usercall.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/docs/gaps-go-to-python.md +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/docs/gaps-python-to-go.md +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/example.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/example2.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/jsons/voll_return.json +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/poetry.lock +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/__init__.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/integration/__init__.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/integration/conftest.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/integration/test_router_client_integration.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/unit/__init__.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/unit/conftest.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/unit/test_default_guard.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/unit/test_guard.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/unit/test_models_actions.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/unit/test_models_message.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/unit/test_models_userstate.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/unit/test_router_http_client.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/unit/test_user_logger.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/tests/unit/test_usercall.py +0 -0
- {chatgraph-1.2.3 → chatgraph-1.2.4}/uv.lock +0 -0
|
@@ -32,6 +32,8 @@ class MessageConsumer:
|
|
|
32
32
|
virtual_host: str = '/',
|
|
33
33
|
heartbeat: int = 60,
|
|
34
34
|
reconnect_interval: float = 5.0,
|
|
35
|
+
x_expires: int = 86400000,
|
|
36
|
+
x_message_ttl: int = 3600000,
|
|
35
37
|
) -> None:
|
|
36
38
|
if heartbeat < 0:
|
|
37
39
|
raise ValueError('heartbeat must be >= 0')
|
|
@@ -39,6 +41,8 @@ class MessageConsumer:
|
|
|
39
41
|
raise ValueError('reconnect_interval must be >= 0')
|
|
40
42
|
self.__virtual_host = virtual_host
|
|
41
43
|
self.__prefetch_count = prefetch_count
|
|
44
|
+
self.__x_expires = x_expires
|
|
45
|
+
self.__x_message_ttl = x_message_ttl
|
|
42
46
|
self.__queue_consume = queue_consume
|
|
43
47
|
self.__amqp_url = amqp_url
|
|
44
48
|
self.__router_url = router_url
|
|
@@ -61,6 +65,8 @@ class MessageConsumer:
|
|
|
61
65
|
router_token_env: str = 'ROUTER_TOKEN',
|
|
62
66
|
heartbeat_env: str = 'RABBIT_HEARTBEAT',
|
|
63
67
|
reconnect_interval_env: str = 'RABBIT_RECONNECT_INTERVAL',
|
|
68
|
+
x_expires_env: str = 'RABBIT_X_EXPIRES',
|
|
69
|
+
x_message_ttl_env: str = 'RABBIT_X_MESSAGE_TTL',
|
|
64
70
|
) -> 'MessageConsumer':
|
|
65
71
|
username = os.getenv(user_env)
|
|
66
72
|
password = os.getenv(pass_env)
|
|
@@ -72,6 +78,8 @@ class MessageConsumer:
|
|
|
72
78
|
router_token = os.getenv(router_token_env)
|
|
73
79
|
heartbeat = os.getenv(heartbeat_env, '60')
|
|
74
80
|
reconnect_interval = os.getenv(reconnect_interval_env, '5.0')
|
|
81
|
+
x_expires = os.getenv(x_expires_env, '86400000')
|
|
82
|
+
x_message_ttl = os.getenv(x_message_ttl_env, '3600000')
|
|
75
83
|
|
|
76
84
|
envs_essentials = {
|
|
77
85
|
username: user_env,
|
|
@@ -98,6 +106,8 @@ class MessageConsumer:
|
|
|
98
106
|
router_token=router_token,
|
|
99
107
|
heartbeat=int(heartbeat),
|
|
100
108
|
reconnect_interval=float(reconnect_interval),
|
|
109
|
+
x_expires=int(x_expires),
|
|
110
|
+
x_message_ttl=int(x_message_ttl),
|
|
101
111
|
)
|
|
102
112
|
|
|
103
113
|
async def __initialize_router(self) -> RouterHTTPClient:
|
|
@@ -119,8 +129,8 @@ class MessageConsumer:
|
|
|
119
129
|
async def __declare_queue(self, channel) -> aio_pika.abc.AbstractQueue:
|
|
120
130
|
arguments = {
|
|
121
131
|
'x-dead-letter-exchange': 'log_error',
|
|
122
|
-
'x-expires':
|
|
123
|
-
'x-message-ttl':
|
|
132
|
+
'x-expires': self.__x_expires,
|
|
133
|
+
'x-message-ttl': self.__x_message_ttl,
|
|
124
134
|
}
|
|
125
135
|
queue = await channel.declare_queue(
|
|
126
136
|
self.__queue_consume,
|
|
@@ -162,11 +162,33 @@ class TestDeclareQueue:
|
|
|
162
162
|
arguments={
|
|
163
163
|
'x-dead-letter-exchange': 'log_error',
|
|
164
164
|
'x-expires': 86400000,
|
|
165
|
-
'x-message-ttl':
|
|
165
|
+
'x-message-ttl': 3600000,
|
|
166
166
|
},
|
|
167
167
|
)
|
|
168
168
|
assert result is mock_queue
|
|
169
169
|
|
|
170
|
+
@pytest.mark.asyncio
|
|
171
|
+
async def test_declares_queue_with_custom_ttl_arguments(self):
|
|
172
|
+
consumer = make_consumer(
|
|
173
|
+
queue_consume='my_queue', x_expires=60000, x_message_ttl=10000
|
|
174
|
+
)
|
|
175
|
+
mock_queue = MagicMock()
|
|
176
|
+
mock_queue.bind = AsyncMock()
|
|
177
|
+
mock_channel = AsyncMock()
|
|
178
|
+
mock_channel.declare_queue = AsyncMock(return_value=mock_queue)
|
|
179
|
+
|
|
180
|
+
await consumer._MessageConsumer__declare_queue(mock_channel)
|
|
181
|
+
|
|
182
|
+
mock_channel.declare_queue.assert_called_once_with(
|
|
183
|
+
'my_queue',
|
|
184
|
+
durable=True,
|
|
185
|
+
arguments={
|
|
186
|
+
'x-dead-letter-exchange': 'log_error',
|
|
187
|
+
'x-expires': 60000,
|
|
188
|
+
'x-message-ttl': 10000,
|
|
189
|
+
},
|
|
190
|
+
)
|
|
191
|
+
|
|
170
192
|
@pytest.mark.asyncio
|
|
171
193
|
async def test_binds_queue_with_expected_exchange_and_routing_key(self):
|
|
172
194
|
consumer = make_consumer(
|
|
@@ -362,3 +384,20 @@ class TestLoadDotenv:
|
|
|
362
384
|
|
|
363
385
|
assert consumer._MessageConsumer__heartbeat == 60
|
|
364
386
|
assert consumer._MessageConsumer__reconnect_interval == 5.0
|
|
387
|
+
assert consumer._MessageConsumer__x_expires == 86400000
|
|
388
|
+
assert consumer._MessageConsumer__x_message_ttl == 3600000
|
|
389
|
+
|
|
390
|
+
def test_loads_custom_ttl_from_env(self, monkeypatch):
|
|
391
|
+
monkeypatch.setenv('RABBIT_USER', 'user')
|
|
392
|
+
monkeypatch.setenv('RABBIT_PASS', 'pass')
|
|
393
|
+
monkeypatch.setenv('RABBIT_URI', 'rabbitmq.example.com:5672')
|
|
394
|
+
monkeypatch.setenv('RABBIT_QUEUE', 'test_queue')
|
|
395
|
+
monkeypatch.setenv('ROUTER_URL', 'http://router')
|
|
396
|
+
monkeypatch.setenv('ROUTER_TOKEN', 'token')
|
|
397
|
+
monkeypatch.setenv('RABBIT_X_EXPIRES', '60000')
|
|
398
|
+
monkeypatch.setenv('RABBIT_X_MESSAGE_TTL', '10000')
|
|
399
|
+
|
|
400
|
+
consumer = MessageConsumer.load_dotenv()
|
|
401
|
+
|
|
402
|
+
assert consumer._MessageConsumer__x_expires == 60000
|
|
403
|
+
assert consumer._MessageConsumer__x_message_ttl == 10000
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|