[Golang micro services] "delete notification email" functionality - in a separate micro service?

Hi all,

At work, we have written a micro service which provides a REST API for project creation. It is basically a CRUD wrapper on a DB table. It has its own DB table which it manages, but needs to make some calls to a satellite system whenever it modifies a line in that table. This makes is already pretty large.

We want to add new functionality: the same micro service should be able to run in API mode, where it exposes its rest API, but also in command line mode.

In command line mode, running it makes it send an “delete notification email” to the owner of each project which is about to expire in 12, 6 or 1 days. If I run it with a certain flag it will only send one email to a single project.

To achieve this “delete notification email” functionality, I query for the projects which are about to expire, email their owner, and if any such email fails to be sent, I make a call to another satellite system.

Does it make sense to have one micro service for the rest API, which does mainly CRUD operations, and a separate microservice, which is triggered perriodically by a cronjob and does the email query and sending ?

Is there any benefit if we were to keep both functionality in a single, larger, micro service, and either call it in cli mode or API mode ?

Both modes of usage use the same data in slightly different ways. If these two ways share business rules on the data and deal with the same domain objects, I’d argue that keeping them in a single cohesive service is fine.

Splitting services always comes with a cost: additional communication between services, changing APIs, increased deployment and configuration complexity. These costs should not be underestimated.

I suggest to look at Domain Driven Design (DDD) for designing services. If the two modes of usage can reasonably fall into the same Bounded Context, this is a strong indication to keep them in a single service.

Maybe you can try to design your service so that both the REST and the CLI modes are only thin wrappers around a common core of business objects and rules.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.