Similar questions were asked a few times, but as every use-case can be different I thought it worth to ask it again with the specific case I'm facing with. So, we are developing micro-services using .netCore. Let's call these services ServiceA, ServiceB, ServiceC.
Common entities
If ServiceA calls ServiceC, then ServiceC responds with a JSON content which can be serialized into ResponseC object.
This means, that both ServiceA and ServiceC should know ResponseC class. At this point I see two possibilities. ResponseC class can be in a shared library and both ServiceA and ServiceC should have a reference to this shared library. However I read statements like do not share libraries among micro-services. This leads to an other possible solution. Let's introduce ResponseC class in both micro-services, but then somehow I find this a bit against maintainability, because of code duplication.
Common logic
Both ServiceA and ServiceB communicates with ServiceC. When communicating with ServiceC we intend to have some policy regarding read and connection timeout and regarding the maximum number of retries. These values are configurable and there is also some common parts in the retry logic to be able to read the relevant values from the configuration file and to wrap the http calls. The question is pretty much the same like in the previous case, because I either put these classes into a shared library or I basically introduce the same classes in both ServiceA and ServiceB. These classes are quite simple and generic, so at the moment I cannot imagine, that these classes will change frequently.
So the question is, that what is better in these cases, duplicate code and having independent micro-services or introduce a shared library which makes these services dependent?