Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions cq/_core/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
)


@injection.injectable(
ignore_type_hint=True,
inject=False,
on=CommandBus,
mode="fallback",
)
def new_command_bus(*, threadsafe: bool | None = None) -> Bus[Command, Any]:
bus = SimpleBus(command_handler.manager)
transaction_scope_middleware = InjectionScopeMiddleware(
Expand All @@ -45,27 +51,21 @@ def new_command_bus(*, threadsafe: bool | None = None) -> Bus[Command, Any]:
return bus


@injection.injectable(
ignore_type_hint=True,
inject=False,
on=EventBus,
mode="fallback",
)
def new_event_bus() -> Bus[Event, None]:
return TaskBus(event_handler.manager)


@injection.injectable(
ignore_type_hint=True,
inject=False,
on=QueryBus,
mode="fallback",
)
def new_query_bus() -> Bus[Query, Any]:
return SimpleBus(query_handler.manager)


@injection.injectable(inject=False, mode="fallback")
def _() -> CommandBus: # type: ignore[type-arg]
return new_command_bus()


@injection.injectable(inject=False, mode="fallback")
def _() -> EventBus:
return new_event_bus()


@injection.injectable(inject=False, mode="fallback")
def _() -> QueryBus: # type: ignore[type-arg]
return new_query_bus()


del _
Loading