Application & domain

services

Problem

  • Service can call other service
  • There is mess with DB transaction control

Handler

Service Foo

Service Bar
(controls DB transaction)

Handler

Problem

Solution

  • Introduce layers
  • Control DB transaction in one place

Application service

  • Called only by handler (gRPC, HTTP, Kafka, CLI)
  • Controls DB transaction
  • Calls business logic (domain services, model's methods)

Domain service

  • Called only by handler or application service
  • Knows nothing about DB transactions
  • Calls model's methods or other domain services

Handler

Service Foo

Handler

Solution

Application Service

Application Service

Service Bar

Handler

Application service

Domain service

Model

Business operation with DB tx

Handler

Domain service

Model

Business operation without DB tx

Read more

BE sync: Application & domain services

By Volodymyr Kupriienko

BE sync: Application & domain services

  • 87