Skip to content

Conversation

@sawaca96
Copy link
Owner

@sawaca96 sawaca96 commented Feb 5, 2023

No description provided.

Comment on lines +63 to +65
@listens_for(models.Product, "load") # type: ignore
def receive_load(product: models.Product, context: QueryContext) -> None:
product.events = list()
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 이유는 모르겠으나, 해당 함수에서 product를 print하면 에러가 발생.
  • 해당 함수가 없으면 orm에 events가 매핑되지 않아서, 에러 발생.

Comment on lines +31 to +38
await self._commit()
await self._publish_events()

async def _publish_events(self) -> None:
for product in self.repo._seen:
while product.events:
event = product.events.pop(0)
await messagebus.handle(event)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

영속성 저장소를 거치지 않는 로직이 있을 수 있지 않을까?

Copy link
Owner Author

@sawaca96 sawaca96 Feb 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

책에서 소개한 방법들중 개인적으로 서비스가 제일 괜찮지 않나? 라는 생각이 들었다. 책에서는 서비스계층이 이벤트 처리와 무관하게 된다는 장점이 있다고 소개하는데, 공감이 되질 않았다.

서비스가 오케스트레이션의 역할이라 하면 더 잘 어울리지 않나?

물론 uow에 숨김으로써 캡슐화가 이루어지게 되고 코드반복을 줄일 수 있는 장점이 존재하는 것 같긴하다.

Comment on lines +42 to +46
async def _add(self, product: models.Product) -> None:
self._session.add(product)
await self._session.flush()

async def get(self, sku: str) -> models.Product:
async def _get(self, sku: str) -> models.Product:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

책에서 소개하기도 하지만, uow와 마찬가지로 언더바로 처리한게 뭔가 맘에 안드는 것 같다.

@sawaca96 sawaca96 merged commit f9b7fd6 into main Feb 6, 2023
@sawaca96 sawaca96 deleted the ch08 branch February 6, 2023 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants