Skip to content

Commit 8add998

Browse files
authored
Changing bus instances lifetime
1 parent c2bba37 commit 8add998

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

cq/_core/message.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
)
3434

3535

36-
@injection.singleton(inject=False, mode="fallback")
36+
@injection.injectable(inject=False, mode="fallback")
3737
def new_command_bus() -> CommandBus: # type: ignore[type-arg]
3838
bus = SimpleBus(command_handler.manager)
3939
transaction_scope_middleware = InjectionScopeMiddleware(
@@ -44,11 +44,11 @@ def new_command_bus() -> CommandBus: # type: ignore[type-arg]
4444
return bus
4545

4646

47-
@injection.singleton(inject=False, mode="fallback")
47+
@injection.injectable(inject=False, mode="fallback")
4848
def new_event_bus() -> EventBus:
4949
return TaskBus(event_handler.manager)
5050

5151

52-
@injection.singleton(inject=False, mode="fallback")
52+
@injection.injectable(inject=False, mode="fallback")
5353
def new_query_bus() -> QueryBus: # type: ignore[type-arg]
5454
return SimpleBus(query_handler.manager)

documentation/fastapi-example.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Here's an example of its integration:
77
```python
88
from cq import CommandBus, command_handler, new_command_bus
99
from fastapi import FastAPI, status
10-
from injection import injectable, singleton
10+
from injection import injectable
1111
from injection.ext.fastapi import Inject
1212
from pydantic import BaseModel
1313

@@ -16,7 +16,7 @@ from pydantic import BaseModel
1616
@injectable
1717
class ExampleService: ...
1818

19-
@singleton
19+
@injectable
2020
def override_command_bus_recipe() -> CommandBus:
2121
bus = new_command_bus()
2222
bus.add_middlewares(...) # Add middlewares here

uv.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)