-
-
Notifications
You must be signed in to change notification settings - Fork 137
Open
Description
Hello @vardius
Thank you for sharing this library, it is very helpful in many regards!
My question is about your choice of appending the metadata in the aggregate itself. Eg.
func (u *User) trackChange(ctx context.Context, event *domain.Event) error {
var meta domain.EventMetadata
if i, hasIdentity := identity.FromContext(ctx); hasIdentity {
meta.Identity = i
}
if m, ok := metadata.FromContext(ctx); ok {
meta.IPAddress = m.IPAddress
meta.UserAgent = m.UserAgent
meta.Referer = m.Referer
}
if !meta.IsEmpty() {
event.WithMetadata(&meta)
}
u.changes = append(u.changes, event)
u.version++
return nil
}Seeing the UserAgent or IP exposed in the aggregate feels a bit like pollution of a domain with application/infra data.
I understand that the aggregate essentially proxies this data from the command handler, which usually is acceptable practice, as aggregate is not making use of that data.
I am wondering if you would not mind sharing your thoughts as to why you chose to enrich the event in the aggregate as opposed to eg. in the aggregate repository implementation.
Thanks again for sharing!
Metadata
Metadata
Assignees
Labels
No labels