Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I want to use the microservices pattern in a complex system. The thing is that I have some methods that I'll use in many microservices, GetAccounts for example. Would I have to implement that method in each microservice? What would be the best way to perform this?

What I have tried:

I have been thinking in create a collection of shared methods. Something like a Utils library but I believe that is not part of the microservices pattern. Maybe I need more information about microservices and understand it. Thanks in advance and sorry for my english, I'm learning.
Posted
Updated 6-Jan-19 22:54pm
v3

Best way would be to define your context and domains, and use these kind of methods as service API to fetch common data from a specific microservice instead of repeating the same code everywhere.

In your example of getAccount, you must have a microservice which manages accounts and getAccount should be you service API.
 
Share this answer
 
Put your shared methods in its own Class Library project. You can then add a reference to this project from your other microservices projects and use them however you need.
 
Share this answer
 
First of all, Microservices is not a pattern is a software architecture in the SOA field. This is very imprtant to understand.
Unlike SOA, Microservices Architecture (MSA) tries to share as less as possible, means that do not share any common functionalities between microservices and make them boudned context. For more information you can read my set of articls about MSA.

Dive into Microservices Architecture - Part I[^]

Cheers,
AH
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900