Search code examples
architecturemicroservices

How to share code between micro services?


For example, I have a project which has 4 micro services: client-web, admin-web, client-api, admin-api.

These four micro services should share one DB code, should I make the DB code as a submodule of git and use it in each micro service?

does it against micro service principle?


Solution

    1. Create a library.
    2. Version the library with semantic versioning and create a package using the package management functionality of your environment (e.g. Nuget if you're on .NET).
    3. Include the package as dependency in the micro services.