python-cq 0.8.0__tar.gz → 0.9.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.
- {python_cq-0.8.0 → python_cq-0.9.0}/PKG-INFO +1 -1
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/__init__.py +2 -0
- python_cq-0.9.0/cq/_core/defer.py +10 -0
- python_cq-0.9.0/cq/ext/fastapi.py +44 -0
- python_cq-0.9.0/cq/ext/fastapi.pyi +5 -0
- python_cq-0.9.0/cq/py.typed +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/pyproject.toml +3 -1
- {python_cq-0.8.0 → python_cq-0.9.0}/.gitignore +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/LICENSE +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/README.md +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/_core/__init__.py +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/_core/dispatcher/__init__.py +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/_core/dispatcher/base.py +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/_core/dispatcher/bus.py +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/_core/dispatcher/pipe.py +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/_core/handler.py +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/_core/message.py +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/_core/middleware.py +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/_core/related_events.py +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/_core/scope.py +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/exceptions.py +0 -0
- {python_cq-0.8.0/cq/middlewares → python_cq-0.9.0/cq/ext}/__init__.py +0 -0
- /python_cq-0.8.0/cq/py.typed → /python_cq-0.9.0/cq/middlewares/__init__.py +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/middlewares/retry.py +0 -0
- {python_cq-0.8.0 → python_cq-0.9.0}/cq/middlewares/scope.py +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from ._core.defer import DeferredBus
|
|
1
2
|
from ._core.dispatcher.bus import Bus
|
|
2
3
|
from ._core.dispatcher.pipe import Pipe
|
|
3
4
|
from ._core.message import (
|
|
@@ -25,6 +26,7 @@ __all__ = (
|
|
|
25
26
|
"CQScope",
|
|
26
27
|
"Command",
|
|
27
28
|
"CommandBus",
|
|
29
|
+
"DeferredBus",
|
|
28
30
|
"Event",
|
|
29
31
|
"EventBus",
|
|
30
32
|
"Middleware",
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Annotated, Any
|
|
3
|
+
|
|
4
|
+
from fastapi import BackgroundTasks, Depends
|
|
5
|
+
from injection.ext.fastapi import Inject
|
|
6
|
+
|
|
7
|
+
from cq import Bus, Command, CommandBus, DeferredBus, Event, EventBus, Query, QueryBus
|
|
8
|
+
|
|
9
|
+
__all__ = ("DeferredCommandBus", "DeferredEventBus", "DeferredQueryBus")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass(repr=False, eq=False, frozen=True, slots=True)
|
|
13
|
+
class FastAPIDeferredBus[I](DeferredBus[I]):
|
|
14
|
+
background_tasks: BackgroundTasks
|
|
15
|
+
bus: Bus[I, Any]
|
|
16
|
+
|
|
17
|
+
async def defer(self, input_value: I, /) -> None:
|
|
18
|
+
self.background_tasks.add_task(self.bus.dispatch, input_value)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
async def new_deferred_command_bus[T](
|
|
22
|
+
background_tasks: BackgroundTasks,
|
|
23
|
+
command_bus: Inject[CommandBus[T]],
|
|
24
|
+
) -> DeferredBus[Command]:
|
|
25
|
+
return FastAPIDeferredBus(background_tasks, command_bus)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
async def new_deferred_event_bus(
|
|
29
|
+
background_tasks: BackgroundTasks,
|
|
30
|
+
event_bus: Inject[EventBus],
|
|
31
|
+
) -> DeferredBus[Event]:
|
|
32
|
+
return FastAPIDeferredBus(background_tasks, event_bus)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
async def new_deferred_query_bus[T](
|
|
36
|
+
background_tasks: BackgroundTasks,
|
|
37
|
+
query_bus: Inject[QueryBus[T]],
|
|
38
|
+
) -> DeferredBus[Query]:
|
|
39
|
+
return FastAPIDeferredBus(background_tasks, query_bus)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
DeferredCommandBus = Annotated[DeferredBus[Command], Depends(new_deferred_command_bus)]
|
|
43
|
+
DeferredEventBus = Annotated[DeferredBus[Event], Depends(new_deferred_event_bus)]
|
|
44
|
+
DeferredQueryBus = Annotated[DeferredBus[Query], Depends(new_deferred_query_bus)]
|
|
File without changes
|
|
@@ -14,6 +14,8 @@ example = [
|
|
|
14
14
|
"pydantic",
|
|
15
15
|
]
|
|
16
16
|
test = [
|
|
17
|
+
"fastapi",
|
|
18
|
+
"httpx",
|
|
17
19
|
"pytest",
|
|
18
20
|
"pytest-asyncio",
|
|
19
21
|
"pytest-cov",
|
|
@@ -21,7 +23,7 @@ test = [
|
|
|
21
23
|
|
|
22
24
|
[project]
|
|
23
25
|
name = "python-cq"
|
|
24
|
-
version = "0.
|
|
26
|
+
version = "0.9.0"
|
|
25
27
|
description = "Lightweight CQRS library for async Python projects."
|
|
26
28
|
license = "MIT"
|
|
27
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
|
|
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
|