mehdihadeli / go-food-delivery-microservices

🍕 A practical and imaginary food delivery microservices, built with golang, domain-driven design, cqrs, event sourcing, vertical slice architecture, event-driven architecture, and the latest technologies.
MIT License
837 stars 85 forks source link

Question: Introduce Service #85

Closed iambudi closed 9 months ago

iambudi commented 1 year ago

Hi, Thank you so much for sharing this repo. I learn a lot and really like the way you organize the code. I have two questions:

  1. What if CreateOrder (/command/create_order_handler.go) requires aggregate action for calculating discount from third party services, or creating booking stock. Should we introduce a coordinator service on top of the command or we just execute them inside command?
  2. What about the data model, should we create one for the service or we just use domain model directly?
github-actions[bot] commented 1 year ago

Welcome to go-ecommerce-microservices. Thank you for reporting your first issue. Please check out our contributor guide.

mehdihadeli commented 1 year ago

Hi, Thanks for your feedback.

  1. there are multiple approaches for handling this, for example passing abstraction of our service as a dependency to action parameter or another approach getting data from third party in our command handler and pass it as a dependency to our action. Here there is a good repository and possible approaches for that, also this twitter thread
  2. we should have persistence ignorance domain model, it should not have any tags related to database, yes it is possible for example this is a sample in my c# code base. But if we use gorm for example we should have separated data model with gorm tags and separated domain model with its actions