python-cq 0.22.1__tar.gz → 0.23.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.22.1 → python_cq-0.23.0}/PKG-INFO +2 -2
- {python_cq-0.22.1 → python_cq-0.23.0}/cq/__init__.py +26 -23
- {python_cq-0.22.1 → python_cq-0.23.0}/cq/_core/message.py +1 -1
- {python_cq-0.22.1 → python_cq-0.23.0}/cq/_core/middleware.py +1 -1
- {python_cq-0.22.1/cq/_core → python_cq-0.23.0/cq/_core/queuing}/pump.py +1 -1
- {python_cq-0.22.1/cq/_core → python_cq-0.23.0/cq/_core/queuing}/queues/memory.py +3 -3
- python_cq-0.22.1/cq/_core/pipetools.py → python_cq-0.23.0/cq/_core/routing/command_pipeline.py +5 -5
- {python_cq-0.22.1/cq/_core → python_cq-0.23.0/cq/_core/routing}/dispatchers/bus.py +5 -5
- {python_cq-0.22.1/cq/_core → python_cq-0.23.0/cq/_core/routing}/dispatchers/lazy.py +2 -2
- {python_cq-0.22.1/cq/_core → python_cq-0.23.0/cq/_core/routing}/dispatchers/pipe.py +1 -1
- {python_cq-0.22.1/cq/_core → python_cq-0.23.0/cq/_core/routing}/handler.py +1 -1
- python_cq-0.22.1/cq/_core/cq.py → python_cq-0.23.0/cq/_core/routing/router.py +7 -7
- {python_cq-0.22.1 → python_cq-0.23.0}/cq/ext/injection.py +1 -1
- python_cq-0.23.0/cq/middlewares/__init__.py +0 -0
- python_cq-0.23.0/cq/py.typed +0 -0
- {python_cq-0.22.1 → python_cq-0.23.0}/pyproject.toml +1 -1
- {python_cq-0.22.1 → python_cq-0.23.0}/.gitignore +0 -0
- {python_cq-0.22.1 → python_cq-0.23.0}/LICENSE +0 -0
- {python_cq-0.22.1 → python_cq-0.23.0}/cq/_core/__init__.py +0 -0
- {python_cq-0.22.1 → python_cq-0.23.0}/cq/_core/common/__init__.py +0 -0
- {python_cq-0.22.1 → python_cq-0.23.0}/cq/_core/common/typing.py +0 -0
- {python_cq-0.22.1/cq/_core/dispatchers → python_cq-0.23.0/cq/_core/queuing}/__init__.py +0 -0
- {python_cq-0.22.1/cq/_core → python_cq-0.23.0/cq/_core/queuing}/queues/__init__.py +0 -0
- {python_cq-0.22.1/cq/_core → python_cq-0.23.0/cq/_core/queuing}/queues/abc.py +0 -0
- {python_cq-0.22.1 → python_cq-0.23.0}/cq/_core/related_events.py +0 -0
- {python_cq-0.22.1/cq/ext → python_cq-0.23.0/cq/_core/routing}/__init__.py +0 -0
- {python_cq-0.22.1/cq/_core → python_cq-0.23.0/cq/_core/routing}/di.py +0 -0
- {python_cq-0.22.1/cq/middlewares → python_cq-0.23.0/cq/_core/routing/dispatchers}/__init__.py +0 -0
- {python_cq-0.22.1/cq/_core → python_cq-0.23.0/cq/_core/routing}/dispatchers/abc.py +0 -0
- {python_cq-0.22.1 → python_cq-0.23.0}/cq/exceptions.py +0 -0
- /python_cq-0.22.1/cq/py.typed → /python_cq-0.23.0/cq/ext/__init__.py +0 -0
- {python_cq-0.22.1 → python_cq-0.23.0}/cq/middlewares/contextlib.py +0 -0
- {python_cq-0.22.1 → python_cq-0.23.0}/cq/middlewares/exc.py +0 -0
- {python_cq-0.22.1 → python_cq-0.23.0}/cq/middlewares/retry.py +0 -0
- {python_cq-0.22.1 → python_cq-0.23.0}/docs/index.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: python-cq
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.23.0
|
|
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
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
from ._core.cq import CQ
|
|
2
|
-
from ._core.di import DIAdapter
|
|
3
|
-
from ._core.di import NoDI as _NoDI
|
|
4
|
-
from ._core.dispatchers.abc import Dispatcher
|
|
5
|
-
from ._core.dispatchers.bus import Bus
|
|
6
|
-
from ._core.dispatchers.pipe import ContextPipeline, Pipe
|
|
7
1
|
from ._core.message import (
|
|
8
2
|
AnyCommandBus,
|
|
9
3
|
Command,
|
|
@@ -14,14 +8,20 @@ from ._core.message import (
|
|
|
14
8
|
QueryBus,
|
|
15
9
|
)
|
|
16
10
|
from ._core.middleware import Middleware, MiddlewareResult, resolve_handler_source
|
|
17
|
-
from ._core.
|
|
18
|
-
from ._core.
|
|
19
|
-
from ._core.queues.
|
|
20
|
-
from ._core.queues.memory import MemoryQueue
|
|
11
|
+
from ._core.queuing.pump import Pump
|
|
12
|
+
from ._core.queuing.queues.abc import Consumer, Delivery, Producer, Queue
|
|
13
|
+
from ._core.queuing.queues.memory import MemoryQueue
|
|
21
14
|
from ._core.related_events import AnyIORelatedEvents, RelatedEvents
|
|
15
|
+
from ._core.routing.command_pipeline import (
|
|
16
|
+
ContextCommandPipeline as _ContextCommandPipeline,
|
|
17
|
+
)
|
|
18
|
+
from ._core.routing.di import DIAdapter
|
|
19
|
+
from ._core.routing.dispatchers.abc import Dispatcher
|
|
20
|
+
from ._core.routing.dispatchers.bus import Bus
|
|
21
|
+
from ._core.routing.dispatchers.pipe import ContextPipeline, Pipe
|
|
22
|
+
from ._core.routing.router import Router
|
|
22
23
|
|
|
23
24
|
__all__ = (
|
|
24
|
-
"CQ",
|
|
25
25
|
"AnyCommandBus",
|
|
26
26
|
"AnyIORelatedEvents",
|
|
27
27
|
"Bus",
|
|
@@ -45,7 +45,8 @@ __all__ = (
|
|
|
45
45
|
"QueryBus",
|
|
46
46
|
"Queue",
|
|
47
47
|
"RelatedEvents",
|
|
48
|
-
"
|
|
48
|
+
"Router",
|
|
49
|
+
"__router__",
|
|
49
50
|
"command_handler",
|
|
50
51
|
"event_handler",
|
|
51
52
|
"new_command_bus",
|
|
@@ -55,28 +56,30 @@ __all__ = (
|
|
|
55
56
|
"resolve_handler_source",
|
|
56
57
|
)
|
|
57
58
|
|
|
59
|
+
|
|
58
60
|
try:
|
|
59
|
-
from .ext.injection import InjectionAdapter
|
|
61
|
+
from .ext.injection import InjectionAdapter
|
|
60
62
|
|
|
61
63
|
except ImportError: # pragma: no cover
|
|
62
|
-
|
|
64
|
+
__router__ = Router()
|
|
63
65
|
|
|
64
66
|
else:
|
|
65
|
-
|
|
67
|
+
__router__ = Router(InjectionAdapter())
|
|
68
|
+
del InjectionAdapter
|
|
66
69
|
|
|
67
|
-
|
|
70
|
+
__router__.register_defaults()
|
|
68
71
|
|
|
69
|
-
command_handler =
|
|
70
|
-
event_handler =
|
|
71
|
-
query_handler =
|
|
72
|
+
command_handler = __router__.command_handler
|
|
73
|
+
event_handler = __router__.event_handler
|
|
74
|
+
query_handler = __router__.query_handler
|
|
72
75
|
|
|
73
|
-
new_command_bus =
|
|
74
|
-
new_event_bus =
|
|
75
|
-
new_query_bus =
|
|
76
|
+
new_command_bus = __router__.new_command_bus
|
|
77
|
+
new_event_bus = __router__.new_event_bus
|
|
78
|
+
new_query_bus = __router__.new_query_bus
|
|
76
79
|
|
|
77
80
|
|
|
78
81
|
class ContextCommandPipeline[C: Command](_ContextCommandPipeline[C]):
|
|
79
82
|
__slots__ = ()
|
|
80
83
|
|
|
81
|
-
def __init__(self, di: DIAdapter =
|
|
84
|
+
def __init__(self, di: DIAdapter = __router__.di) -> None:
|
|
82
85
|
super().__init__(di)
|
|
@@ -3,7 +3,7 @@ from dataclasses import dataclass, field
|
|
|
3
3
|
from inspect import isasyncgenfunction
|
|
4
4
|
from typing import Any, Concatenate, Self, TypeGuard
|
|
5
5
|
|
|
6
|
-
from cq._core.handler import HandleFunction, HandlerType
|
|
6
|
+
from cq._core.routing.handler import HandleFunction, HandlerType
|
|
7
7
|
from cq.exceptions import MiddlewareError
|
|
8
8
|
|
|
9
9
|
type MiddlewareResult[T] = AsyncGenerator[None, T]
|
|
@@ -6,7 +6,7 @@ from typing import Any, Self
|
|
|
6
6
|
import anyio
|
|
7
7
|
|
|
8
8
|
from cq._core.middleware import Middleware, MiddlewareGroup
|
|
9
|
-
from cq._core.queues.abc import Consumer
|
|
9
|
+
from cq._core.queuing.queues.abc import Consumer
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@dataclass(repr=False, eq=False, frozen=True, slots=True)
|
|
@@ -7,8 +7,8 @@ import anyio
|
|
|
7
7
|
from anyio.abc import ObjectReceiveStream, ObjectSendStream
|
|
8
8
|
|
|
9
9
|
from cq._core.middleware import Middleware
|
|
10
|
-
from cq._core.pump import Pump
|
|
11
|
-
from cq._core.queues.abc import Delivery, Queue
|
|
10
|
+
from cq._core.queuing.pump import Pump
|
|
11
|
+
from cq._core.queuing.queues.abc import Delivery, Queue
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class MemoryQueue[T](Queue[T]):
|
|
@@ -17,7 +17,7 @@ class MemoryQueue[T](Queue[T]):
|
|
|
17
17
|
__consumer: ObjectReceiveStream[T]
|
|
18
18
|
__producer: ObjectSendStream[T]
|
|
19
19
|
|
|
20
|
-
def __init__(self, maxsize:
|
|
20
|
+
def __init__(self, maxsize: float = 0) -> None:
|
|
21
21
|
self.__producer, self.__consumer = anyio.create_memory_object_stream(maxsize)
|
|
22
22
|
|
|
23
23
|
async def __aenter__(self) -> Self:
|
python_cq-0.22.1/cq/_core/pipetools.py → python_cq-0.23.0/cq/_core/routing/command_pipeline.py
RENAMED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
from typing import TYPE_CHECKING, Any, Self, overload
|
|
2
2
|
|
|
3
|
-
from cq import Dispatcher
|
|
4
3
|
from cq._core.common.typing import Decorator
|
|
5
|
-
from cq._core.
|
|
6
|
-
from cq._core.
|
|
7
|
-
from cq._core.dispatchers.
|
|
4
|
+
from cq._core.message import Command, CommandBus, Query, QueryBus
|
|
5
|
+
from cq._core.routing.di import DIAdapter
|
|
6
|
+
from cq._core.routing.dispatchers.abc import Dispatcher
|
|
7
|
+
from cq._core.routing.dispatchers.lazy import LazyDispatcher
|
|
8
|
+
from cq._core.routing.dispatchers.pipe import (
|
|
8
9
|
ContextPipeline,
|
|
9
10
|
ConvertMethod,
|
|
10
11
|
ConvertMethodAsync,
|
|
11
12
|
ConvertMethodSync,
|
|
12
13
|
)
|
|
13
|
-
from cq._core.message import Command, CommandBus, Query, QueryBus
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class ContextCommandPipeline[C: Command](ContextPipeline[C]):
|
|
@@ -5,15 +5,15 @@ from typing import Any, Protocol, Self, runtime_checkable
|
|
|
5
5
|
import anyio
|
|
6
6
|
from anyio.abc import TaskGroup
|
|
7
7
|
|
|
8
|
-
from cq._core.
|
|
9
|
-
from cq._core.
|
|
8
|
+
from cq._core.middleware import Middleware
|
|
9
|
+
from cq._core.routing.dispatchers.abc import BaseDispatcher, Dispatcher
|
|
10
|
+
from cq._core.routing.handler import (
|
|
10
11
|
HandleFunction,
|
|
11
12
|
HandlerFactory,
|
|
12
13
|
HandlerRegistry,
|
|
13
14
|
MultipleHandlerRegistry,
|
|
14
15
|
SingleHandlerRegistry,
|
|
15
16
|
)
|
|
16
|
-
from cq._core.middleware import Middleware
|
|
17
17
|
|
|
18
18
|
type Listener[T] = Callable[[T], Awaitable[Any]]
|
|
19
19
|
|
|
@@ -82,7 +82,7 @@ class SimpleBus[I, O](BaseBus[I, O]):
|
|
|
82
82
|
async with anyio.create_task_group() as task_group:
|
|
83
83
|
self._trigger_listeners(message, task_group)
|
|
84
84
|
|
|
85
|
-
for handler in self._handlers_from(
|
|
85
|
+
for handler in self._handlers_from(message.__class__):
|
|
86
86
|
return await self._invoke(handler, message, handler.fail_silently)
|
|
87
87
|
|
|
88
88
|
return NotImplemented
|
|
@@ -98,7 +98,7 @@ class TaskBus[I](BaseBus[I, None]):
|
|
|
98
98
|
async with anyio.create_task_group() as task_group:
|
|
99
99
|
self._trigger_listeners(message, task_group)
|
|
100
100
|
|
|
101
|
-
for handler in self._handlers_from(
|
|
101
|
+
for handler in self._handlers_from(message.__class__):
|
|
102
102
|
task_group.start_soon(
|
|
103
103
|
self._invoke,
|
|
104
104
|
handler,
|
|
@@ -2,8 +2,8 @@ from collections.abc import Awaitable, Callable
|
|
|
2
2
|
from types import GenericAlias
|
|
3
3
|
from typing import TypeAliasType
|
|
4
4
|
|
|
5
|
-
from cq._core.di import DIAdapter
|
|
6
|
-
from cq._core.dispatchers.abc import Dispatcher
|
|
5
|
+
from cq._core.routing.di import DIAdapter
|
|
6
|
+
from cq._core.routing.dispatchers.abc import Dispatcher
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class LazyDispatcher[I, O](Dispatcher[I, O]):
|
|
@@ -14,8 +14,8 @@ from typing import (
|
|
|
14
14
|
)
|
|
15
15
|
|
|
16
16
|
from cq._core.common.typing import Decorator, Method
|
|
17
|
-
from cq._core.dispatchers.abc import BaseDispatcher, Dispatcher
|
|
18
17
|
from cq._core.middleware import Middleware, MiddlewareGroup
|
|
18
|
+
from cq._core.routing.dispatchers.abc import BaseDispatcher, Dispatcher
|
|
19
19
|
|
|
20
20
|
type ConvertAsync[**P, I, O] = Callable[Concatenate[O, P], Awaitable[I]]
|
|
21
21
|
type ConvertSync[**P, I, O] = Callable[Concatenate[O, P], I]
|
|
@@ -10,7 +10,7 @@ from typing import TYPE_CHECKING, Any, Protocol, Self, overload, runtime_checkab
|
|
|
10
10
|
from type_analyzer import MatchingTypesConfig, iter_matching_types, matching_types
|
|
11
11
|
|
|
12
12
|
from cq._core.common.typing import Decorator
|
|
13
|
-
from cq._core.di import DIAdapter, NoDI
|
|
13
|
+
from cq._core.routing.di import DIAdapter, NoDI
|
|
14
14
|
|
|
15
15
|
type HandlerType[**P, T] = type[Handler[P, T]]
|
|
16
16
|
type HandlerFactory[**P, T] = Callable[..., Awaitable[Handler[P, T]]]
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
from collections.abc import KeysView
|
|
2
2
|
from typing import Any, Self
|
|
3
3
|
|
|
4
|
-
from cq._core.
|
|
5
|
-
from cq._core.
|
|
6
|
-
from cq._core.
|
|
4
|
+
from cq._core.message import Command, Event, Query
|
|
5
|
+
from cq._core.routing.di import DIAdapter, NoDI
|
|
6
|
+
from cq._core.routing.dispatchers.bus import Bus, SimpleBus, TaskBus
|
|
7
|
+
from cq._core.routing.handler import (
|
|
7
8
|
HandlerDecorator,
|
|
8
9
|
HandlerRegistry,
|
|
9
10
|
MultipleHandlerRegistry,
|
|
10
11
|
SingleHandlerRegistry,
|
|
11
12
|
)
|
|
12
|
-
from cq._core.message import Command, Event, Query
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
class
|
|
15
|
+
class Router:
|
|
16
16
|
__slots__ = ("__command_registry", "__di", "__event_registry", "__query_registry")
|
|
17
17
|
|
|
18
18
|
__command_registry: HandlerRegistry[Command, Any]
|
|
@@ -20,8 +20,8 @@ class CQ:
|
|
|
20
20
|
__event_registry: HandlerRegistry[Event, Any]
|
|
21
21
|
__query_registry: HandlerRegistry[Query, Any]
|
|
22
22
|
|
|
23
|
-
def __init__(self, di: DIAdapter, /) -> None:
|
|
24
|
-
self.__di = di
|
|
23
|
+
def __init__(self, di: DIAdapter | None = None, /) -> None:
|
|
24
|
+
self.__di = di or NoDI()
|
|
25
25
|
self.__command_registry = SingleHandlerRegistry()
|
|
26
26
|
self.__event_registry = MultipleHandlerRegistry()
|
|
27
27
|
self.__query_registry = SingleHandlerRegistry()
|
|
@@ -7,10 +7,10 @@ from typing import Any
|
|
|
7
7
|
from injection import Module, adefine_scope, mod
|
|
8
8
|
from injection.exceptions import ScopeAlreadyDefinedError
|
|
9
9
|
|
|
10
|
-
from cq._core.di import DIAdapter
|
|
11
10
|
from cq._core.message import Command, CommandBus, EventBus, QueryBus
|
|
12
11
|
from cq._core.middleware import Middleware, MiddlewareResult
|
|
13
12
|
from cq._core.related_events import AnyIORelatedEvents, RelatedEvents
|
|
13
|
+
from cq._core.routing.di import DIAdapter
|
|
14
14
|
|
|
15
15
|
__all__ = ("CQScope", "InjectionAdapter", "InjectionScopeMiddleware")
|
|
16
16
|
|
|
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
|
{python_cq-0.22.1/cq/middlewares → python_cq-0.23.0/cq/_core/routing/dispatchers}/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|