I have a question that has more to do with microse...
# server
c
I have a question that has more to do with microservices than with Kotlin but I think here are the experts. I have my Profile/User - Service (A): there profiles are created and root information is stored e.g.: .
Copy code
User: {name: "potter", street: "hogwards-street", type: "cleaner"}
I publish these to my message broker and consumed it in an another service (B). Now the service (B) only needs
{name: String, type: String}
. Should I still share the full model of
User
as interface between the services or are these other types of
User
models?
😶 1
in my opinion these are two different models, one
AUserModel
and
BUserMode
c
What event is causing Service A to emit this event? Profile/user creation?
c
any mutation on the profile
c
The approach that I’ve taken in the past is to emit events that describe the domain objects affected and the event that happened, from the perspective of the sending service. So I’d be inclined to ask ā€œhow much information about a user does Service A want to expose to the rest of the system?ā€ instead of asking what precise fields Service B needs for one particular use case.
c
service b needs as said only a small part, at the moment it’s about 3/10 fields. i send the full profile as a message, because a other service needs also other parts of the model, but in service b i translated only a part of it. šŸ˜…
c
What you’ve done sounds good to me then. Incidentally, most of what my opinions about how to do microservices comes from the book Microservices Patterns by Chris Richardson. It’s a looong book but it held my attention from start to finish and I’d recommend it if you haven’t already read it. Two of the patterns in that book that are particularly relevant here (and which are probably the source of my opinions on this stuff) are summarised on Mr Richardson’s website: • https://microservices.io/patterns/data/domain-event.html • https://microservices.io/patterns/data/event-sourcing.html (There’s waaaay more detail in the book.)
ā¤ļø 1