Contents
- 1 Why is it important to share code between microservices?
- 2 How to share source code and schema between microservices?
- 3 How to share DTO across microservices [ 3.1 ]?
- 4 When to share WSDL between client and server?
- 5 Why do different teams work on different repositories?
- 6 What are the problems of sharing code between projects?
Microservices provide increased modularity and separation for your development process. Many services will use the same code, so sharing code between them is critical for your development and maintenance efforts. However, coupling services through shared libs might ruin the point of having multiple different services.
Other options are to use git submodule (less desired) or git subtree (better) in order to include the source code in a single “parent” repository. Regarding schema – if you want to play by the book, then each microservice has its own database.
3.1. Sharing DTO Using Client Modules (Libraries) A microservice requires certain information from other services to process any request. Let’s say there is a third microservice that receives order payment requests. Unlike the Order service, this service requires different customer information:
How are microservices affected by code duplications?
Microservices are prawned to code duplications. For example, any service which is used by other services will cause all these other services to duplicate the code needed in order to use that service’s API.
How to share and SYNC code between microservices-DZone?
Instead of coupling your microservices together via common libraries, you can simply isolate and sync any reusable code using the Bit’s ability to isolate and track source code among projects. You can even still install this code with NPM in different repos, and still make changes from any end.
Share a WSDL when using SOAP (not the service model code, since they should be generated from the WSDL). When using REST, have distinct models (copy yes but not share) for client and server. As soon as the second or third consumer comes into play, you’ll get into trouble.
Why do different teams work on different repositories?
Different teams work on different repositories. Points 2 and 3 are only significant if point 1 holds. By splitting our repositories, I significantly decreased the delays suffered by our offsite colleagues, reduced disk consumption, and improved network traffic. 4 and 5 are more subtle.
What are the problems of sharing code between projects?
First, submodules only work on the master branch, which causes problems for rapid development. Secondly, submodules increase coupling between projects, which makes it hard to work on cross-repository assignments. Finally, a submodule repository is oblivious to its own nesting and the existence of dependent repositories.
How can I share code with other projects?
Git enables you to make one repository a subdirectory of another repository, creating a single working tree for the entire project, so that a repository can utilize code from another repository. As for many other teams, this solution did not last for us. First, submodules only work on the master branch, which causes problems for rapid development.