Reputation: 577
I have a workspace with many microservices and many times I want to perform conversions between the DTOs of different services (e.g. convert the response of one service into a request for another). I'm having a hard time deciding where to put these conversions due to cargo rejecting cyclic dependencies. Some solutions I've thought of:
A
to crate B
(A
->B
) belong in crate A
(always the 'from' side). This means crate A
depends on crate B
but this precludes crate B
from depending on A
if it ever calls A
directly (which actually happens in our codebase)convert
crate where we store conversions, gated by both features for both involved crates. This means convert
depends on both A
and B
so neither can use these conversions directly or otherwise that would be a cylic dependency!I'll take any ideas to solve this cleanly
Upvotes: 0
Views: 49