Skip to content

Commit f1a16e2

Browse files
committed
uow now needs a messagebus
1 parent 6cdf3a2 commit f1a16e2

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎src/allocation/service_layer/unit_of_work.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
# pylint: disable=attribute-defined-outside-init
1+
# pylint: disable=attribute-defined-outside-init, ungrouped-imports
22
from __future__ import annotations
33
import abc
4+
from typing import TYPE_CHECKING
45
from sqlalchemy import create_engine
56
from sqlalchemy.orm import sessionmaker
6-
from sqlalchemy.orm.session import Session
7-
87

98
from allocation import config
109
from allocation.adapters import repository
1110
from . import messagebus
1211

12+
if TYPE_CHECKING:
13+
from sqlalchemy.orm.session import Session
14+
1315

1416

1517
class AbstractUnitOfWork(abc.ABC):
18+
bus: messagebus.MessageBus
1619
products: repository.AbstractRepository
1720

1821
def __enter__(self) -> AbstractUnitOfWork:
@@ -29,7 +32,7 @@ def publish_events(self):
2932
for product in self.products.seen:
3033
while product.events:
3134
event = product.events.pop(0)
32-
messagebus.handle(event, uow=self)
35+
self.bus.handle(event)
3336

3437
@abc.abstractmethod
3538
def _commit(self):

0 commit comments

Comments
 (0)