Reputation: 45
I am wondering about how should i implement certain things. I am new to the Microservices architecture, but i think i understood how it works in a certain way. But i am very confused in the shared code, and shared projects thing.
I am developing a new system which contains about 50 microservice including ApiGateWays as well. I am working only in ASP.net Core
I want to standardize the requests and responses. I created a new project which contians only models, so no logic included, just a few interface and some classes.
Is it hurting the core principals of microservice architecture any ways? I know in a certain point it does, but i develop only in ASP.Net core, and it is a very basic no logic model collection, which standard in the whole system, so if i would create a node.js project then i would use the same model there as well.
The other thing is the HealthCheck middleware. I am thinking to create this in a shared project and i would just reference it from the microservices. This would contain logic, so i am confused, i think that if i would copy and paste it to everywhere than it would not be better than creating a shared project for it. It must be a standard thing, so if i have to change it for some reason then i would have to change it every single microservice as well.
What do you think about this? It is a good practice to do it? I know this is not the best practice, i know if i would work in a team i won't try to use the HealthCheck in a shared project, because that would cause more issues than it would solve, because which team should develop that and so on...
And the last thing, somebody can help me to understand this whole code sharing in microservices, if it is possible, i read a lot of articles about it, but everybody says that you can share, but you should avoid it. Please help me if you have time for it, i think a lot of newbie how jumps into microservices, and developing alone has this confusion in his mind.
Thanks for your time and i hope this would help some newbie in Microservices, which has the same confusion in Sharing code between microservices
Upvotes: 1
Views: 836
Reputation: 493
In the microservices world, there will still be a need for shared libraries. Healthchecks is one of them.
On MSDN docs this is described in detail.
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?view=aspnetcore-3.1
A healthchecks shared library would that use that code and provide ways for your micriservices to register healthcheck endpoints with a call of one extension method.
Also that way the endpoints registered would be the same for all microservices.
Tell me if you need more info and I elaborate more.
Upvotes: 1