xtr-orm-messenger 7.0.0__tar.gz → 7.2.0__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.
Files changed (28) hide show
  1. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/PKG-INFO +14 -3
  2. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/README.md +13 -2
  3. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/pyproject.toml +1 -1
  4. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/pyproject.toml.orig +1 -1
  5. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/.agents/skills/xtr-orm-messenger/SKILL.md +7 -1
  6. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/orm_receiver.py +9 -1
  7. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/orm_transport.py +19 -3
  8. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/LICENSE +0 -0
  9. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/__init__.py +0 -0
  10. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/exception/__init__.py +0 -0
  11. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/exception/invalid_orm_dsn_error.py +0 -0
  12. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/exception/orm_messenger_error.py +0 -0
  13. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/exception/transport_error.py +0 -0
  14. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/py.typed +0 -0
  15. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/recipe/__init__.py +0 -0
  16. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/recipe/manifest.toml +0 -0
  17. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/__init__.py +0 -0
  18. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/_database_errors.py +0 -0
  19. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/connection.py +0 -0
  20. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/messages_table.py +0 -0
  21. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/messages_table_driver.py +0 -0
  22. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/messages_tables.py +0 -0
  23. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/orm_options.py +0 -0
  24. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/orm_received_stamp.py +0 -0
  25. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/orm_sender.py +0 -0
  26. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/orm_transport_factory.py +0 -0
  27. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/postgresql_notifier.py +0 -0
  28. {xtr_orm_messenger-7.0.0 → xtr_orm_messenger-7.2.0}/src/xtr_orm_messenger/transport/stored_message.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xtr-orm-messenger
3
- Version: 7.0.0
3
+ Version: 7.2.0
4
4
  Summary: A database transport for xtr-messenger: messages kept in a table on an xtr-orm connection, claimed by workers, delayed, redelivered and woken by notifications.
5
5
  Keywords: message-bus,message-queue,transport,database,sqlalchemy,asyncio
6
6
  Author: Xterr
@@ -121,6 +121,9 @@ an `ErrorDetailsStamp` with why the last one failed. Once its attempts run out t
121
121
  the `failure_queue` of the same table, `failed` unless named otherwise, where `count()`, `all()`
122
122
  and `find()` on a transport reading that queue show it, and a worker consuming it tries it
123
123
  again, with a fresh count. A message failing for good in the failure queue itself is deleted.
124
+ With a `failure_transport` configured for the transport, the worker sends a message whose
125
+ attempts ran out there instead, and the row is deleted: `failure_queue` is where it goes only
126
+ when the configuration names no failure transport.
124
127
  The worker asks the transport before it announces a failure, so `WorkerMessageFailedEvent`
125
128
  carries `will_retry=True` for an attempt that will be made again.
126
129
 
@@ -223,6 +226,14 @@ await transport.setup() # create the table ahead of time
223
226
  refused when longer than `redeliver_timeout`. A worker already renews what it holds on its own;
224
227
  call it for a message held some other way.
225
228
 
229
+ These are the messenger's `ListableReceiverInterface`, `MessageCountAwareInterface` and
230
+ `SetupableTransportInterface`, so the console commands read a queue through them:
231
+ `messenger:setup-transports`, `messenger:stats`, `messenger:show`, and the
232
+ `messenger:failed:*` commands on the transport reading `failure_queue` — name it the
233
+ configuration's `failure_transport`. A message moved to `failure_queue` carries a
234
+ `SentToFailureTransportStamp` naming the transport it failed on and when, which
235
+ `messenger:failed:show` shows and `--failed-after` / `--failed-before` select by.
236
+
226
237
  ## Use in an application
227
238
 
228
239
  Everything adding this package to an application takes — and, read backwards, what removing it
@@ -283,8 +294,8 @@ Everything this library raises derives from `OrmMessengerError`, itself a
283
294
 
284
295
  ## Upgrading
285
296
 
286
- What changes for an application moving to 7.0, and how to keep the old behaviour where that is
287
- still possible: [Upgrading to 7.0](../../UPGRADING.md#xtr-orm-messenger).
297
+ What changes for an application moving to 7.0 and to 7.1, and how to keep the old behaviour
298
+ where that is still possible: [Upgrading](../../UPGRADING.md).
288
299
 
289
300
  ## Development
290
301
 
@@ -98,6 +98,9 @@ an `ErrorDetailsStamp` with why the last one failed. Once its attempts run out t
98
98
  the `failure_queue` of the same table, `failed` unless named otherwise, where `count()`, `all()`
99
99
  and `find()` on a transport reading that queue show it, and a worker consuming it tries it
100
100
  again, with a fresh count. A message failing for good in the failure queue itself is deleted.
101
+ With a `failure_transport` configured for the transport, the worker sends a message whose
102
+ attempts ran out there instead, and the row is deleted: `failure_queue` is where it goes only
103
+ when the configuration names no failure transport.
101
104
  The worker asks the transport before it announces a failure, so `WorkerMessageFailedEvent`
102
105
  carries `will_retry=True` for an attempt that will be made again.
103
106
 
@@ -200,6 +203,14 @@ await transport.setup() # create the table ahead of time
200
203
  refused when longer than `redeliver_timeout`. A worker already renews what it holds on its own;
201
204
  call it for a message held some other way.
202
205
 
206
+ These are the messenger's `ListableReceiverInterface`, `MessageCountAwareInterface` and
207
+ `SetupableTransportInterface`, so the console commands read a queue through them:
208
+ `messenger:setup-transports`, `messenger:stats`, `messenger:show`, and the
209
+ `messenger:failed:*` commands on the transport reading `failure_queue` — name it the
210
+ configuration's `failure_transport`. A message moved to `failure_queue` carries a
211
+ `SentToFailureTransportStamp` naming the transport it failed on and when, which
212
+ `messenger:failed:show` shows and `--failed-after` / `--failed-before` select by.
213
+
203
214
  ## Use in an application
204
215
 
205
216
  Everything adding this package to an application takes — and, read backwards, what removing it
@@ -260,8 +271,8 @@ Everything this library raises derives from `OrmMessengerError`, itself a
260
271
 
261
272
  ## Upgrading
262
273
 
263
- What changes for an application moving to 7.0, and how to keep the old behaviour where that is
264
- still possible: [Upgrading to 7.0](../../UPGRADING.md#xtr-orm-messenger).
274
+ What changes for an application moving to 7.0 and to 7.1, and how to keep the old behaviour
275
+ where that is still possible: [Upgrading](../../UPGRADING.md).
265
276
 
266
277
  ## Development
267
278
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "xtr-orm-messenger"
3
- version = "7.0.0"
3
+ version = "7.2.0"
4
4
  description = "A database transport for xtr-messenger: messages kept in a table on an xtr-orm connection, claimed by workers, delayed, redelivered and woken by notifications."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.14.4"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "xtr-orm-messenger"
3
- version = "7.0.0"
3
+ version = "7.2.0"
4
4
  description = "A database transport for xtr-messenger: messages kept in a table on an xtr-orm connection, claimed by workers, delayed, redelivered and woken by notifications."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.14.4"
@@ -26,7 +26,8 @@ skill; for connections and migrations, `xtr-orm`.
26
26
  `orm:migrations:diff` writes it; `messages_tables(bus_config, connection, default)` names them.
27
27
  - Acknowledging deletes the row. Rejecting puts it back in its queue with a `RedeliveryStamp`
28
28
  while attempts are left, then moves it to `failure_queue` — consume that queue to try it
29
- again; a failure there deletes it. `transport.will_retry(envelope)` says which, and the
29
+ again; a failure there deletes it. With a `failure_transport` configured, the worker sends it
30
+ there instead and the row is deleted. `transport.will_retry(envelope)` says which, and the
30
31
  worker's `WorkerMessageFailedEvent.will_retry` follows it. While a worker holds a message its claim is renewed every half of
31
32
  `redeliver_timeout`; a row not renewed that long (a dead or frozen worker) is claimed again,
32
33
  so handlers must be idempotent.
@@ -79,6 +80,11 @@ await transport.find(message_id)
79
80
  await transport.keepalive(envelope, seconds=600) # a message held outside a worker
80
81
  ```
81
82
 
83
+ The console reads a queue the same way: `messenger:setup-transports`, `messenger:stats`,
84
+ `messenger:show <transport> [id]`, and `messenger:failed:show|retry|remove` on a transport
85
+ reading `failure_queue`, named the configuration's `failure_transport`. A message moved there
86
+ carries `SentToFailureTransportStamp(original_receiver_name, failed_at)`.
87
+
82
88
  ## Testing
83
89
 
84
90
  Run against a SQLite file per test (`sqlite+aiosqlite:///{tmp_path / 'app.sqlite'}`) and freeze
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
  import asyncio
6
6
  import logging
7
7
  import secrets
8
+ from datetime import UTC
8
9
  from typing import TYPE_CHECKING, Final, final, override
9
10
 
10
11
  from sqlalchemy.exc import DBAPIError
@@ -16,6 +17,7 @@ from xtr_messenger import (
16
17
  ReceivedStamp,
17
18
  ReceiverInterface,
18
19
  RedeliveryStamp,
20
+ SentToFailureTransportStamp,
19
21
  TransportMessageIdStamp,
20
22
  )
21
23
 
@@ -62,7 +64,11 @@ class OrmReceiver(ReceiverInterface):
62
64
  reason it failed in an :class:`~xtr_messenger.ErrorDetailsStamp`. Once
63
65
  its ``max_attempts`` are spent it is moved to the ``failure_queue`` with
64
66
  a fresh count, so whoever consumes that queue gets to try it again; a
65
- message failing for good in the failure queue itself is deleted.
67
+ message failing for good in the failure queue itself is deleted. A
68
+ message moved there carries a
69
+ :class:`~xtr_messenger.SentToFailureTransportStamp` naming this
70
+ transport and when it was moved, which the ``messenger:failed:*``
71
+ commands show and select it by.
66
72
 
67
73
  Workers polling one table run into each other's transactions; a conflict
68
74
  says nothing about the message, so a poll sits through
@@ -172,6 +178,8 @@ class OrmReceiver(ReceiverInterface):
172
178
  elif options.queue != options.failure_queue:
173
179
  queue = options.failure_queue
174
180
  delay_ms = 0
181
+ moved_at = self._clock.now().astimezone(UTC)
182
+ next_try = next_try.with_stamps(SentToFailureTransportStamp(self._name, moved_at))
175
183
  else:
176
184
  await self._settle(message_id, self._connection.reject, "reject")
177
185
  return
@@ -5,7 +5,12 @@ from __future__ import annotations
5
5
  from typing import TYPE_CHECKING, final, override
6
6
 
7
7
  from sqlalchemy.exc import DBAPIError
8
- from xtr_messenger import TransportInterface
8
+ from xtr_messenger import (
9
+ ListableReceiverInterface,
10
+ MessageCountAwareInterface,
11
+ SetupableTransportInterface,
12
+ TransportInterface,
13
+ )
9
14
 
10
15
  from xtr_orm_messenger.exception import TransportError
11
16
 
@@ -25,12 +30,19 @@ __all__ = ["OrmTransport"]
25
30
 
26
31
 
27
32
  @final
28
- class OrmTransport(TransportInterface):
33
+ class OrmTransport(
34
+ TransportInterface,
35
+ ListableReceiverInterface,
36
+ MessageCountAwareInterface,
37
+ SetupableTransportInterface,
38
+ ):
29
39
  """Sends to, receives from and lists one queue of a messages table.
30
40
 
31
41
  Beyond sending and receiving, the queue can be looked into — counted,
32
42
  listed, one message found by id — and a message a long handler holds can
33
- be kept from being handed out again.
43
+ be kept from being handed out again. That is what the console's
44
+ ``messenger:setup-transports``, ``messenger:stats``, ``messenger:show``
45
+ and ``messenger:failed:*`` commands read it through.
34
46
  """
35
47
 
36
48
  __slots__ = ("_connection", "_name", "_receiver", "_sender")
@@ -120,6 +132,7 @@ class OrmTransport(TransportInterface):
120
132
  except DBAPIError as error:
121
133
  raise TransportError(self._name, "keep a message alive", str(error.orig)) from error
122
134
 
135
+ @override
123
136
  async def find(self, message_id: str) -> Envelope | None:
124
137
  """Return the envelope kept as ``message_id`` in this queue, or ``None``.
125
138
 
@@ -133,6 +146,7 @@ class OrmTransport(TransportInterface):
133
146
  raise TransportError(self._name, "find a message", str(error.orig)) from error
134
147
  return None if stored is None else self._receiver.decode(stored)
135
148
 
149
+ @override
136
150
  async def all(self, limit: int | None = None) -> AsyncIterator[Envelope]:
137
151
  """Yield the envelopes a worker could claim now, oldest first, ``limit`` at most.
138
152
 
@@ -146,6 +160,7 @@ class OrmTransport(TransportInterface):
146
160
  except DBAPIError as error:
147
161
  raise TransportError(self._name, "list messages", str(error.orig)) from error
148
162
 
163
+ @override
149
164
  async def count(self) -> int:
150
165
  """Return how many messages a worker could claim now.
151
166
 
@@ -157,6 +172,7 @@ class OrmTransport(TransportInterface):
157
172
  except DBAPIError as error:
158
173
  raise TransportError(self._name, "count messages", str(error.orig)) from error
159
174
 
175
+ @override
160
176
  async def setup(self) -> None:
161
177
  """Create the messages table if it does not exist.
162
178