Search code examples
microservices

microservice architecure : a layer between service and its client


I'm quite a newbie to microservices architecture. I'm referring to one of my clients projects with microservice architecture. It has one of the service as Notification

Order ->(talks to)-> Notification client(as a lib) -> calls api from - > Notification service.

I don't really understand the purpose of having a client in between, where in it has a few exceptions handled for hitting the api. I understand, microservices communicate via api gateway but I feel Notification Client is just an addon. I tried to figure out the terminology used for this kind of implementation but in vain.

Please help me understand this use case.


Solution

  • It may feel that the client is redundant if Order service is the only microservice that is consuming the APIs. But considering the notification service is getting used by a few more microservices having a notification client as a lib makes sense. The reason is,

    • The client lib will wrap all the API calls and their implementation so that other services can simply call it just like a method.
    • Other services don't have to write REST client for notification service when it wants to make use of the APIs.
    • Same client lib can be shared by other microservices without actually writing code to call the APIs.
    • Any changes/fixes made to the notification service can be cascaded to other services by simply changing the version of the client lib.