python-cq 0.5.1__tar.gz → 0.6.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.5.1 → python_cq-0.6.1}/PKG-INFO +1 -2
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/__init__.py +0 -4
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/_core/message.py +8 -36
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/_core/related_events.py +2 -2
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/middlewares/retry.py +2 -2
- {python_cq-0.5.1 → python_cq-0.6.1}/pyproject.toml +3 -8
- python_cq-0.5.1/cq/_core/dto.py +0 -10
- {python_cq-0.5.1 → python_cq-0.6.1}/.gitignore +0 -0
- {python_cq-0.5.1 → python_cq-0.6.1}/README.md +0 -0
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/_core/__init__.py +0 -0
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/_core/dispatcher/__init__.py +0 -0
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/_core/dispatcher/base.py +0 -0
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/_core/dispatcher/bus.py +0 -0
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/_core/dispatcher/pipe.py +0 -0
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/_core/handler.py +0 -0
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/_core/middleware.py +0 -0
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/_core/scope.py +0 -0
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/exceptions.py +0 -0
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/middlewares/__init__.py +0 -0
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/middlewares/scope.py +0 -0
- {python_cq-0.5.1 → python_cq-0.6.1}/cq/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-cq
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.1
|
|
4
4
|
Summary: Lightweight CQRS library.
|
|
5
5
|
Project-URL: Repository, https://github.com/100nm/python-cq
|
|
6
6
|
Author: remimd
|
|
@@ -19,7 +19,6 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
19
19
|
Classifier: Typing :: Typed
|
|
20
20
|
Requires-Python: <4,>=3.12
|
|
21
21
|
Requires-Dist: anyio
|
|
22
|
-
Requires-Dist: pydantic<3,>=2
|
|
23
22
|
Requires-Dist: python-injection
|
|
24
23
|
Description-Content-Type: text/markdown
|
|
25
24
|
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
from ._core.dispatcher.bus import Bus
|
|
2
2
|
from ._core.dispatcher.pipe import Pipe
|
|
3
|
-
from ._core.dto import DTO
|
|
4
3
|
from ._core.message import (
|
|
5
4
|
AnyCommandBus,
|
|
6
5
|
Command,
|
|
7
6
|
CommandBus,
|
|
8
7
|
Event,
|
|
9
8
|
EventBus,
|
|
10
|
-
Message,
|
|
11
9
|
Query,
|
|
12
10
|
QueryBus,
|
|
13
11
|
command_handler,
|
|
@@ -27,10 +25,8 @@ __all__ = (
|
|
|
27
25
|
"CQScope",
|
|
28
26
|
"Command",
|
|
29
27
|
"CommandBus",
|
|
30
|
-
"DTO",
|
|
31
28
|
"Event",
|
|
32
29
|
"EventBus",
|
|
33
|
-
"Message",
|
|
34
30
|
"Middleware",
|
|
35
31
|
"MiddlewareResult",
|
|
36
32
|
"Pipe",
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
from abc import ABC
|
|
2
1
|
from typing import Any
|
|
3
2
|
|
|
4
3
|
import injection
|
|
5
4
|
|
|
6
5
|
from cq._core.dispatcher.bus import Bus, SimpleBus, TaskBus
|
|
7
|
-
from cq._core.dto import DTO
|
|
8
6
|
from cq._core.handler import (
|
|
9
7
|
HandlerDecorator,
|
|
10
8
|
MultipleHandlerManager,
|
|
@@ -13,22 +11,9 @@ from cq._core.handler import (
|
|
|
13
11
|
from cq._core.scope import CQScope
|
|
14
12
|
from cq.middlewares.scope import InjectionScopeMiddleware
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class Command(Message, ABC):
|
|
22
|
-
__slots__ = ()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class Event(Message, ABC):
|
|
26
|
-
__slots__ = ()
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class Query(Message, ABC):
|
|
30
|
-
__slots__ = ()
|
|
31
|
-
|
|
14
|
+
Command = object
|
|
15
|
+
Event = object
|
|
16
|
+
Query = object
|
|
32
17
|
|
|
33
18
|
type CommandBus[T] = Bus[Command, T]
|
|
34
19
|
type EventBus = Bus[Event, None]
|
|
@@ -48,31 +33,18 @@ query_handler: HandlerDecorator[Query, Any] = HandlerDecorator(
|
|
|
48
33
|
)
|
|
49
34
|
|
|
50
35
|
|
|
51
|
-
@injection.singleton(
|
|
52
|
-
|
|
53
|
-
ignore_type_hint=True, # type: ignore[call-arg]
|
|
54
|
-
inject=False,
|
|
55
|
-
mode="fallback",
|
|
56
|
-
)
|
|
57
|
-
def new_command_bus[T]() -> CommandBus[T]:
|
|
36
|
+
@injection.singleton(inject=False, mode="fallback")
|
|
37
|
+
def new_command_bus() -> CommandBus: # type: ignore[type-arg]
|
|
58
38
|
bus = SimpleBus(command_handler.manager)
|
|
59
39
|
bus.add_middlewares(InjectionScopeMiddleware(CQScope.ON_COMMAND))
|
|
60
40
|
return bus
|
|
61
41
|
|
|
62
42
|
|
|
63
|
-
@injection.singleton(
|
|
64
|
-
inject=False,
|
|
65
|
-
mode="fallback",
|
|
66
|
-
)
|
|
43
|
+
@injection.singleton(inject=False, mode="fallback")
|
|
67
44
|
def new_event_bus() -> EventBus:
|
|
68
45
|
return TaskBus(event_handler.manager)
|
|
69
46
|
|
|
70
47
|
|
|
71
|
-
@injection.singleton(
|
|
72
|
-
|
|
73
|
-
ignore_type_hint=True, # type: ignore[call-arg]
|
|
74
|
-
inject=False,
|
|
75
|
-
mode="fallback",
|
|
76
|
-
)
|
|
77
|
-
def new_query_bus[T]() -> QueryBus[T]:
|
|
48
|
+
@injection.singleton(inject=False, mode="fallback")
|
|
49
|
+
def new_query_bus() -> QueryBus: # type: ignore[type-arg]
|
|
78
50
|
return SimpleBus(query_handler.manager)
|
|
@@ -20,7 +20,7 @@ class RelatedEvents(Protocol):
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
@dataclass(repr=False, eq=False, frozen=True, slots=True)
|
|
23
|
-
class
|
|
23
|
+
class SimpleRelatedEvents(RelatedEvents):
|
|
24
24
|
items: list[Event] = field(default_factory=list)
|
|
25
25
|
|
|
26
26
|
def add(self, *events: Event) -> None:
|
|
@@ -29,7 +29,7 @@ class _RelatedEvents(RelatedEvents):
|
|
|
29
29
|
|
|
30
30
|
@injection.scoped(CQScope.ON_COMMAND, mode="fallback")
|
|
31
31
|
async def related_events_recipe(event_bus: EventBus) -> AsyncIterator[RelatedEvents]:
|
|
32
|
-
yield (instance :=
|
|
32
|
+
yield (instance := SimpleRelatedEvents())
|
|
33
33
|
events = instance.items
|
|
34
34
|
|
|
35
35
|
if not events:
|
|
@@ -10,6 +10,8 @@ dev = [
|
|
|
10
10
|
]
|
|
11
11
|
example = [
|
|
12
12
|
"fastapi",
|
|
13
|
+
"msgspec",
|
|
14
|
+
"pydantic",
|
|
13
15
|
]
|
|
14
16
|
test = [
|
|
15
17
|
"pytest",
|
|
@@ -19,7 +21,7 @@ test = [
|
|
|
19
21
|
|
|
20
22
|
[project]
|
|
21
23
|
name = "python-cq"
|
|
22
|
-
version = "0.
|
|
24
|
+
version = "0.6.1"
|
|
23
25
|
description = "Lightweight CQRS library."
|
|
24
26
|
license = { text = "MIT" }
|
|
25
27
|
readme = "README.md"
|
|
@@ -41,7 +43,6 @@ classifiers = [
|
|
|
41
43
|
]
|
|
42
44
|
dependencies = [
|
|
43
45
|
"anyio",
|
|
44
|
-
"pydantic (>=2, <3)",
|
|
45
46
|
"python-injection",
|
|
46
47
|
]
|
|
47
48
|
|
|
@@ -71,15 +72,9 @@ disallow_subclassing_any = true
|
|
|
71
72
|
disallow_untyped_defs = true
|
|
72
73
|
follow_imports = "silent"
|
|
73
74
|
no_implicit_reexport = true
|
|
74
|
-
plugins = ["pydantic.mypy"]
|
|
75
75
|
warn_redundant_casts = true
|
|
76
76
|
warn_unused_ignores = true
|
|
77
77
|
|
|
78
|
-
[tool.pydantic-mypy]
|
|
79
|
-
init_forbid_extra = true
|
|
80
|
-
init_typed = true
|
|
81
|
-
warn_required_dynamic_aliases = true
|
|
82
|
-
|
|
83
78
|
[tool.pytest.ini_options]
|
|
84
79
|
python_files = "test_*.py"
|
|
85
80
|
addopts = "--tb short --cov ./ --cov-report term-missing:skip-covered"
|
python_cq-0.5.1/cq/_core/dto.py
DELETED
|
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
|