python-cq 0.12.0__tar.gz → 0.12.2__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 (25) hide show
  1. {python_cq-0.12.0 → python_cq-0.12.2}/PKG-INFO +1 -1
  2. {python_cq-0.12.0 → python_cq-0.12.2}/cq/_core/handler.py +4 -3
  3. {python_cq-0.12.0 → python_cq-0.12.2}/cq/_core/message.py +18 -18
  4. {python_cq-0.12.0 → python_cq-0.12.2}/pyproject.toml +1 -1
  5. {python_cq-0.12.0 → python_cq-0.12.2}/.gitignore +0 -0
  6. {python_cq-0.12.0 → python_cq-0.12.2}/LICENSE +0 -0
  7. {python_cq-0.12.0 → python_cq-0.12.2}/README.md +0 -0
  8. {python_cq-0.12.0 → python_cq-0.12.2}/cq/__init__.py +0 -0
  9. {python_cq-0.12.0 → python_cq-0.12.2}/cq/_core/__init__.py +0 -0
  10. {python_cq-0.12.0 → python_cq-0.12.2}/cq/_core/dispatcher/__init__.py +0 -0
  11. {python_cq-0.12.0 → python_cq-0.12.2}/cq/_core/dispatcher/base.py +0 -0
  12. {python_cq-0.12.0 → python_cq-0.12.2}/cq/_core/dispatcher/bus.py +0 -0
  13. {python_cq-0.12.0 → python_cq-0.12.2}/cq/_core/dispatcher/lazy.py +0 -0
  14. {python_cq-0.12.0 → python_cq-0.12.2}/cq/_core/dispatcher/pipe.py +0 -0
  15. {python_cq-0.12.0 → python_cq-0.12.2}/cq/_core/middleware.py +0 -0
  16. {python_cq-0.12.0 → python_cq-0.12.2}/cq/_core/pipetools.py +0 -0
  17. {python_cq-0.12.0 → python_cq-0.12.2}/cq/_core/related_events.py +0 -0
  18. {python_cq-0.12.0 → python_cq-0.12.2}/cq/_core/scope.py +0 -0
  19. {python_cq-0.12.0 → python_cq-0.12.2}/cq/exceptions.py +0 -0
  20. {python_cq-0.12.0 → python_cq-0.12.2}/cq/ext/__init__.py +0 -0
  21. {python_cq-0.12.0 → python_cq-0.12.2}/cq/ext/fastapi.py +0 -0
  22. {python_cq-0.12.0 → python_cq-0.12.2}/cq/middlewares/__init__.py +0 -0
  23. {python_cq-0.12.0 → python_cq-0.12.2}/cq/middlewares/retry.py +0 -0
  24. {python_cq-0.12.0 → python_cq-0.12.2}/cq/middlewares/scope.py +0 -0
  25. {python_cq-0.12.0 → python_cq-0.12.2}/cq/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-cq
3
- Version: 0.12.0
3
+ Version: 0.12.2
4
4
  Summary: Lightweight CQRS library for async Python projects.
5
5
  Project-URL: Repository, https://github.com/100nm/python-cq
6
6
  Author: remimd
@@ -78,14 +78,15 @@ class SingleHandlerManager[I, O](HandlerManager[I, O]):
78
78
  yield _make_handle_function(factory)
79
79
 
80
80
  def subscribe(self, input_type: type[I], factory: HandlerFactory[[I], O]) -> Self:
81
- for key_type in _build_key_types(input_type):
81
+ entries = {key_type: factory for key_type in _build_key_types(input_type)}
82
+
83
+ for key_type in entries:
82
84
  if key_type in self.__factories:
83
85
  raise RuntimeError(
84
86
  f"A handler is already registered for the input type: `{key_type}`."
85
87
  )
86
88
 
87
- self.__factories[key_type] = factory
88
-
89
+ self.__factories.update(entries)
89
90
  return self
90
91
 
91
92
 
@@ -34,6 +34,12 @@ query_handler: Final[HandlerDecorator[Query, Any]] = HandlerDecorator(
34
34
  )
35
35
 
36
36
 
37
+ @injection.injectable(
38
+ ignore_type_hint=True,
39
+ inject=False,
40
+ on=CommandBus,
41
+ mode="fallback",
42
+ )
37
43
  def new_command_bus(*, threadsafe: bool | None = None) -> Bus[Command, Any]:
38
44
  bus = SimpleBus(command_handler.manager)
39
45
  transaction_scope_middleware = InjectionScopeMiddleware(
@@ -45,27 +51,21 @@ def new_command_bus(*, threadsafe: bool | None = None) -> Bus[Command, Any]:
45
51
  return bus
46
52
 
47
53
 
54
+ @injection.injectable(
55
+ ignore_type_hint=True,
56
+ inject=False,
57
+ on=EventBus,
58
+ mode="fallback",
59
+ )
48
60
  def new_event_bus() -> Bus[Event, None]:
49
61
  return TaskBus(event_handler.manager)
50
62
 
51
63
 
64
+ @injection.injectable(
65
+ ignore_type_hint=True,
66
+ inject=False,
67
+ on=QueryBus,
68
+ mode="fallback",
69
+ )
52
70
  def new_query_bus() -> Bus[Query, Any]:
53
71
  return SimpleBus(query_handler.manager)
54
-
55
-
56
- @injection.injectable(inject=False, mode="fallback")
57
- def _() -> CommandBus: # type: ignore[type-arg]
58
- return new_command_bus()
59
-
60
-
61
- @injection.injectable(inject=False, mode="fallback")
62
- def _() -> EventBus:
63
- return new_event_bus()
64
-
65
-
66
- @injection.injectable(inject=False, mode="fallback")
67
- def _() -> QueryBus: # type: ignore[type-arg]
68
- return new_query_bus()
69
-
70
-
71
- del _
@@ -23,7 +23,7 @@ test = [
23
23
 
24
24
  [project]
25
25
  name = "python-cq"
26
- version = "0.12.0"
26
+ version = "0.12.2"
27
27
  description = "Lightweight CQRS library for async Python projects."
28
28
  license = "MIT"
29
29
  license-files = ["LICENSE"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes