Clean architecture for infrastructure service

Viewed 543

I have a service A that is essentially doing this:

  1. Fetches batch of events from external service B.
  2. Based on these events, transforms data from the database and persists it back to the database.
  3. Sends a confirmation that batch was successfully processed to service B.

I'm trying to implement this in a "clean architecture" manner.

Right now, I'm having trouble figuring out correct abstraction for the second step. Should this be a use case? How to call the transformation process (is it a Gateway/Adapter/Mapper)? Does clean architecture even apply to an infrastructure service?

1 Answers

It can be considered as an adapter :

Interfaces / Adapters

  • Retrieve and store data from and to a number of sources (database, network devices, file system, 3rd parties, and so on.)
  • Define interfaces for the data that they need in order to apply some logic. One or more data providers will implement the interface, but the use case doesn’t know where the data is coming from
  • Implement the interfaces defined by the use case
  • There are ways to interact with the application, and typically involve a delivery mechanism (for example, REST APIs, scheduled jobs, GUI, other systems)
  • Trigger a use case and convert the result to the appropriate format for the delivery mechanism ( if your case this matches)
  • the controller for a MVC
Related