python-cq 0.22.0__tar.gz → 0.22.1__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.
- {python_cq-0.22.0 → python_cq-0.22.1}/PKG-INFO +6 -1
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/handler.py +1 -1
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/middleware.py +1 -1
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/queues/abc.py +3 -2
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/queues/memory.py +3 -3
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/ext/injection.py +2 -2
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/middlewares/contextlib.py +4 -3
- {python_cq-0.22.0 → python_cq-0.22.1}/docs/index.md +4 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/pyproject.toml +2 -1
- {python_cq-0.22.0 → python_cq-0.22.1}/.gitignore +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/LICENSE +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/__init__.py +3 -3
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/__init__.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/common/__init__.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/common/typing.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/cq.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/di.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/dispatchers/__init__.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/dispatchers/abc.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/dispatchers/bus.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/dispatchers/lazy.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/dispatchers/pipe.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/message.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/pipetools.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/pump.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/queues/__init__.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/_core/related_events.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/exceptions.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/ext/__init__.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/middlewares/__init__.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/middlewares/exc.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/middlewares/retry.py +0 -0
- {python_cq-0.22.0 → python_cq-0.22.1}/cq/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-cq
|
|
3
|
-
Version: 0.22.
|
|
3
|
+
Version: 0.22.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
|
|
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
21
22
|
Classifier: Topic :: Software Development :: Libraries
|
|
22
23
|
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
23
24
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
@@ -80,23 +81,27 @@ from cq import CommandBus, command_handler
|
|
|
80
81
|
from dataclasses import dataclass
|
|
81
82
|
from injection import inject
|
|
82
83
|
|
|
84
|
+
|
|
83
85
|
@dataclass
|
|
84
86
|
class CreateUserCommand:
|
|
85
87
|
name: str
|
|
86
88
|
email: str
|
|
87
89
|
|
|
90
|
+
|
|
88
91
|
@command_handler
|
|
89
92
|
class CreateUserHandler:
|
|
90
93
|
async def handle(self, command: CreateUserCommand) -> int:
|
|
91
94
|
# ... persist the user, return its id
|
|
92
95
|
return 42
|
|
93
96
|
|
|
97
|
+
|
|
94
98
|
@inject
|
|
95
99
|
async def main(bus: CommandBus[int]) -> None:
|
|
96
100
|
command = CreateUserCommand(name="Ada", email="ada@example.com")
|
|
97
101
|
user_id = await bus.dispatch(command)
|
|
98
102
|
print(f"Created user {user_id}")
|
|
99
103
|
|
|
104
|
+
|
|
100
105
|
asyncio.run(main())
|
|
101
106
|
```
|
|
102
107
|
|
|
@@ -98,7 +98,7 @@ class _GeneratorMiddleware[**P, T]:
|
|
|
98
98
|
while True:
|
|
99
99
|
try:
|
|
100
100
|
value = await call_next(*args, **kwargs)
|
|
101
|
-
except BaseException as exc:
|
|
101
|
+
except BaseException as exc: # noqa: BLE001
|
|
102
102
|
await generator.athrow(exc)
|
|
103
103
|
else:
|
|
104
104
|
await generator.asend(value)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from abc import abstractmethod
|
|
2
2
|
from collections.abc import AsyncIterable
|
|
3
|
-
from
|
|
3
|
+
from contextlib import AbstractAsyncContextManager
|
|
4
|
+
from typing import Protocol, runtime_checkable
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
@runtime_checkable
|
|
@@ -16,7 +17,7 @@ class Producer[T](Protocol):
|
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
@runtime_checkable
|
|
19
|
-
class Delivery[T](
|
|
20
|
+
class Delivery[T](AbstractAsyncContextManager[T], Protocol):
|
|
20
21
|
__slots__ = ()
|
|
21
22
|
|
|
22
23
|
|
|
@@ -51,10 +51,10 @@ class MemoryQueue[T](Queue[T]):
|
|
|
51
51
|
async with (
|
|
52
52
|
Pump(self, dispatcher, fail_silently)
|
|
53
53
|
.add_middlewares(*middlewares)
|
|
54
|
-
.draining(concurrency=concurrency, graceful=True)
|
|
54
|
+
.draining(concurrency=concurrency, graceful=True),
|
|
55
|
+
self,
|
|
55
56
|
):
|
|
56
|
-
|
|
57
|
-
yield self
|
|
57
|
+
yield self
|
|
58
58
|
|
|
59
59
|
async def send(self, message: T, /) -> None:
|
|
60
60
|
await self.__producer.send(message)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
from collections.abc import AsyncIterator
|
|
1
|
+
from collections.abc import AsyncIterator, Awaitable, Callable
|
|
2
2
|
from contextlib import AsyncExitStack
|
|
3
3
|
from dataclasses import dataclass, field
|
|
4
4
|
from enum import StrEnum
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any
|
|
6
6
|
|
|
7
7
|
from injection import Module, adefine_scope, mod
|
|
8
8
|
from injection.exceptions import ScopeAlreadyDefinedError
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from contextlib import AbstractAsyncContextManager, AbstractContextManager
|
|
3
4
|
from dataclasses import dataclass
|
|
4
|
-
from typing import TYPE_CHECKING, Any
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
5
6
|
|
|
6
7
|
if TYPE_CHECKING: # pragma: no cover
|
|
7
8
|
from cq import MiddlewareResult
|
|
@@ -11,7 +12,7 @@ __all__ = ("AsyncContextManagerMiddleware", "ContextManagerMiddleware")
|
|
|
11
12
|
|
|
12
13
|
@dataclass(repr=False, eq=False, frozen=True, slots=True)
|
|
13
14
|
class AsyncContextManagerMiddleware:
|
|
14
|
-
context:
|
|
15
|
+
context: AbstractAsyncContextManager[Any]
|
|
15
16
|
|
|
16
17
|
async def __call__(self, /, *args: Any, **kwargs: Any) -> MiddlewareResult[Any]:
|
|
17
18
|
async with self.context:
|
|
@@ -20,7 +21,7 @@ class AsyncContextManagerMiddleware:
|
|
|
20
21
|
|
|
21
22
|
@dataclass(repr=False, eq=False, frozen=True, slots=True)
|
|
22
23
|
class ContextManagerMiddleware:
|
|
23
|
-
context:
|
|
24
|
+
context: AbstractContextManager[Any]
|
|
24
25
|
|
|
25
26
|
async def __call__(self, /, *args: Any, **kwargs: Any) -> MiddlewareResult[Any]:
|
|
26
27
|
with self.context:
|
|
@@ -49,23 +49,27 @@ from cq import CommandBus, command_handler
|
|
|
49
49
|
from dataclasses import dataclass
|
|
50
50
|
from injection import inject
|
|
51
51
|
|
|
52
|
+
|
|
52
53
|
@dataclass
|
|
53
54
|
class CreateUserCommand:
|
|
54
55
|
name: str
|
|
55
56
|
email: str
|
|
56
57
|
|
|
58
|
+
|
|
57
59
|
@command_handler
|
|
58
60
|
class CreateUserHandler:
|
|
59
61
|
async def handle(self, command: CreateUserCommand) -> int:
|
|
60
62
|
# ... persist the user, return its id
|
|
61
63
|
return 42
|
|
62
64
|
|
|
65
|
+
|
|
63
66
|
@inject
|
|
64
67
|
async def main(bus: CommandBus[int]) -> None:
|
|
65
68
|
command = CreateUserCommand(name="Ada", email="ada@example.com")
|
|
66
69
|
user_id = await bus.dispatch(command)
|
|
67
70
|
print(f"Created user {user_id}")
|
|
68
71
|
|
|
72
|
+
|
|
69
73
|
asyncio.run(main())
|
|
70
74
|
```
|
|
71
75
|
|
|
@@ -20,7 +20,7 @@ test = [
|
|
|
20
20
|
|
|
21
21
|
[project]
|
|
22
22
|
name = "python-cq"
|
|
23
|
-
version = "0.22.
|
|
23
|
+
version = "0.22.1"
|
|
24
24
|
description = "CQRS library for async Python projects."
|
|
25
25
|
license = "MIT"
|
|
26
26
|
license-files = ["LICENSE"]
|
|
@@ -39,6 +39,7 @@ classifiers = [
|
|
|
39
39
|
"Programming Language :: Python :: 3.12",
|
|
40
40
|
"Programming Language :: Python :: 3.13",
|
|
41
41
|
"Programming Language :: Python :: 3.14",
|
|
42
|
+
"Programming Language :: Python :: 3.15",
|
|
42
43
|
"Operating System :: OS Independent",
|
|
43
44
|
"Intended Audience :: Developers",
|
|
44
45
|
"Natural Language :: English",
|
|
File without changes
|
|
File without changes
|
|
@@ -21,18 +21,17 @@ from ._core.queues.memory import MemoryQueue
|
|
|
21
21
|
from ._core.related_events import AnyIORelatedEvents, RelatedEvents
|
|
22
22
|
|
|
23
23
|
__all__ = (
|
|
24
|
-
"
|
|
24
|
+
"CQ",
|
|
25
25
|
"AnyCommandBus",
|
|
26
26
|
"AnyIORelatedEvents",
|
|
27
27
|
"Bus",
|
|
28
|
-
"CQ",
|
|
29
28
|
"Command",
|
|
30
29
|
"CommandBus",
|
|
31
30
|
"Consumer",
|
|
32
31
|
"ContextCommandPipeline",
|
|
33
32
|
"ContextPipeline",
|
|
34
|
-
"Delivery",
|
|
35
33
|
"DIAdapter",
|
|
34
|
+
"Delivery",
|
|
36
35
|
"Dispatcher",
|
|
37
36
|
"Event",
|
|
38
37
|
"EventBus",
|
|
@@ -46,6 +45,7 @@ __all__ = (
|
|
|
46
45
|
"QueryBus",
|
|
47
46
|
"Queue",
|
|
48
47
|
"RelatedEvents",
|
|
48
|
+
"__cq__",
|
|
49
49
|
"command_handler",
|
|
50
50
|
"event_handler",
|
|
51
51
|
"new_command_bus",
|
|
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
|