Reputation: 53
I have two services order service
and Z service
(Z is a hypothetical name). I Have 3 layer in my project (domain, application, infrastructure). The order service has a registration API. The user calls this web service along with a mobile number and other data. In ordering service, in order to receive the Z_ID, this phone number needs to be sent to the order service
I have a method in infrastructure layer for call Z service. But my question is in which layer should I call this method?
Should it be handled as follows in the application layer:
$order = Order::Create($price, $shop);
$Z_id = // call method in infrastructure
$order->setZID($zid);
or the domain layer must request to the infrastructure layer?
Upvotes: 1
Views: 1019
Reputation: 353
You can solve this problem in the following way:
It is worth noting that in this approach domain isn't dependent on infrastructure anymore and as a result it gives you significant flexibility - for example it is easier to change microservice or even use DB instead of HTTP call, this attitude is called hexagonal architecture.
Upvotes: 1