For example, we have an application with microservice architecture. The services communicate with each other using an event bus as follows:
- TeamService subscribes to
UserCreated
event
- UserService publishes the
UserCreated
event
- TeamService stores the user from the
UserCreated
event to its own database
So, we duplicate data in some services. And that's okay in microservices architecture. But what about the code that processes this data? For example, the user might have isPublic
field. If the isPublic
field is false, the user's profile information is visible only to the user himself and to a user with administrator rights.
Thus, UserService and TeamService must have the same code to handle this logic. Or is there another way to handle the isPublic
field without code duplication?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…