python-cq 0.24.0__py3-none-any.whl → 0.25.1__py3-none-any.whl

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.
cq/__init__.py CHANGED
@@ -16,6 +16,7 @@ from ._core.routing.command_pipeline import ContextCommandPipeline
16
16
  from ._core.routing.di import DIAdapter
17
17
  from ._core.routing.dispatchers.abc import Dispatcher
18
18
  from ._core.routing.dispatchers.bus import Bus
19
+ from ._core.routing.dispatchers.functions import dispatch_sequentially
19
20
  from ._core.routing.dispatchers.pipe import ContextPipeline, Pipe
20
21
  from ._core.routing.router import Router
21
22
 
@@ -46,6 +47,7 @@ __all__ = (
46
47
  "Router",
47
48
  "__router__",
48
49
  "command_handler",
50
+ "dispatch_sequentially",
49
51
  "event_handler",
50
52
  "new_command_bus",
51
53
  "new_event_bus",
@@ -25,7 +25,7 @@ class AnyIORelatedEvents(RelatedEvents):
25
25
  task_group: TaskGroup = field(default_factory=create_task_group)
26
26
  history: list[Event] = field(default_factory=list, init=False)
27
27
 
28
- def __bool__(self) -> bool: # pragma: no cover
28
+ def __bool__(self) -> bool:
29
29
  return bool(self.history)
30
30
 
31
31
  async def __aenter__(self) -> Self:
@@ -0,0 +1,11 @@
1
+ from typing import Any
2
+
3
+ from cq._core.routing.dispatchers.abc import Dispatcher
4
+
5
+
6
+ async def dispatch_sequentially[T, *Ts](
7
+ dispatcher: Dispatcher[T, Any],
8
+ /,
9
+ *messages: T,
10
+ ) -> tuple[*Ts]:
11
+ return tuple([await dispatcher.dispatch(message) for message in messages])
cq/middlewares/retry.py CHANGED
@@ -21,6 +21,9 @@ class RetryMiddleware:
21
21
  delay: float = 0,
22
22
  exceptions: Sequence[type[BaseException]] = (Exception,),
23
23
  ) -> None:
24
+ if retry < 1:
25
+ raise ValueError(f"`retry` must be at least 1, got {retry}.")
26
+
24
27
  self.__delay = delay
25
28
  self.__exceptions = tuple(exceptions)
26
29
  self.__retry = retry
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-cq
3
- Version: 0.24.0
3
+ Version: 0.25.1
4
4
  Summary: CQRS library for async Python projects.
5
5
  Project-URL: Documentation, https://python-cq.remimd.dev
6
6
  Project-URL: Repository, https://github.com/100nm/python-cq
@@ -32,8 +32,8 @@ Description-Content-Type: text/markdown
32
32
 
33
33
  # python-cq
34
34
 
35
- [![PyPI - Version](https://img.shields.io/pypi/v/python-cq.svg?color=4051b5&style=for-the-badge)](https://pypi.org/project/python-cq)
36
- [![PyPI - Downloads](https://img.shields.io/pypi/dm/python-cq.svg?color=4051b5&style=for-the-badge)](https://pypistats.org/packages/python-cq)
35
+ [![PyPI - Version](https://shieldcn.dev/pypi/v/python-cq.svg?variant=secondary)](https://pypi.org/project/python-cq)
36
+ [![PyPI - Downloads](https://shieldcn.dev/pypi/dm/python-cq.svg?variant=secondary)](https://pypistats.org/packages/python-cq)
37
37
 
38
38
  **python-cq** is an async-first Python library for organizing code around CQRS. It separates reads (queries), writes (commands), and notifications (events) into dedicated message buses, and lets you plug in any dependency injection framework behind a small protocol.
39
39
 
@@ -1,10 +1,10 @@
1
- cq/__init__.py,sha256=0HISWerIbqoHHk_ZTH43RBRN2fwt1X4KXPBuIj0WF60,1911
1
+ cq/__init__.py,sha256=cIQ_uYKh4vIM_hRt2TCIMpyA35hybQfXqX52QwFpeZk,2011
2
2
  cq/exceptions.py,sha256=lmIpWDbPPwdS9bAAKxUvampA1KKmB706wWaB2mKZyPc,111
3
3
  cq/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cq/_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  cq/_core/message.py,sha256=uyFgiFCm3kVhWFzJ2gBtWNub_cgfCdyXXSJirBW05OQ,286
6
6
  cq/_core/middleware.py,sha256=EKrAXCbDEZmGn9JTGpL06Nd0DflTTFbDB1Z7Ja3CqmI,3710
7
- cq/_core/related_events.py,sha256=vPltQdmQjnfb3eOB2lO6dxqjJEsGOjOyCNj7_2ehNAk,1389
7
+ cq/_core/related_events.py,sha256=msJ0J-ydtxJ5My8qPLhMIFuCCvzbB_WBDD0CTwOEC-0,1369
8
8
  cq/_core/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  cq/_core/common/typing.py,sha256=xtXsqzyATZ0LTVfjB-J4sB6dPKHKrpXqd1bZIkwVljA,504
10
10
  cq/_core/queuing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -20,6 +20,7 @@ cq/_core/routing/router.py,sha256=s6xkFeBosOOTjh5CTwBF64uYu23TSzFRK67xlDjJvPI,26
20
20
  cq/_core/routing/dispatchers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  cq/_core/routing/dispatchers/abc.py,sha256=PKHHrs4lmK5nDAOLI97X_hueHnmarZKFXXX51MCpJDw,1268
22
22
  cq/_core/routing/dispatchers/bus.py,sha256=ZQ1nvSuhLgEvqGMPIgKgWdkKueVzwrTDWeK07TfE57g,3429
23
+ cq/_core/routing/dispatchers/functions.py,sha256=mUYcGDrHkZyX189xkMaA_x0ClWFb0_WjH3jnBHan838,280
23
24
  cq/_core/routing/dispatchers/lazy.py,sha256=ep4vC7lB0_iRZmoC7W5v4nQejEQ3z9NsO1Q_QEYpI_8,731
24
25
  cq/_core/routing/dispatchers/pipe.py,sha256=QmK8m-uerewJVY82Ikf11ixUn-gPAzG23doakIglxyc,9731
25
26
  cq/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -27,8 +28,8 @@ cq/ext/injection.py,sha256=DLdALqRYaJ80wWEcw2wbZRUrNMiZVGg0AdgYIt5FrP8,3150
27
28
  cq/middlewares/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
29
  cq/middlewares/contextlib.py,sha256=_kwbXteGADGuzD-o2pPoPWOeTKiXcPCNuDmpG-f-YnY,875
29
30
  cq/middlewares/exc.py,sha256=ecAMoksj6B4osySSZ9g_cBR35_tiABQdpII-Drxkz44,1604
30
- cq/middlewares/retry.py,sha256=L6X_Wa2TZ0IYNXmi8oexTXQyM_lkjJt5Ew4D-2VzwBY,957
31
- python_cq-0.24.0.dist-info/METADATA,sha256=6ENGI4KWPmBJUKAlUXI45DcYHVIWA3qGogeHqgWY0MQ,4562
32
- python_cq-0.24.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
33
- python_cq-0.24.0.dist-info/licenses/LICENSE,sha256=oC77BOa9kaaQni5rW-Z-ytz3E5h4EVg248BHg9UFgyg,1063
34
- python_cq-0.24.0.dist-info/RECORD,,
31
+ cq/middlewares/retry.py,sha256=WkpMYfAVUR8bnZ1NejX8zeKuPtfCIJlDEj8r4ZkqGBU,1054
32
+ python_cq-0.25.1.dist-info/METADATA,sha256=joDtH5B0cYSWfHLgn0AnWlu5i4aiSRje_xVmqrnzcMA,4528
33
+ python_cq-0.25.1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
34
+ python_cq-0.25.1.dist-info/licenses/LICENSE,sha256=oC77BOa9kaaQni5rW-Z-ytz3E5h4EVg248BHg9UFgyg,1063
35
+ python_cq-0.25.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.32.0
2
+ Generator: hatchling 1.32.4
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any