-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
It would be nice if I could attach some metadata such as the correlation id to a command so that it can be merged into the metadata of the corresponding events.
There are already pure equivalents of Java's ThreadLocal such as monix.eval.TaskLocal and zio.FiberRef that can propagate its local state through the effect context.
A possible use case:
- A http4s middleware generates a correlation id, and embeds it in the fiber (effect context) using
TaskLocal/FiberRef - The Aecor runtime serializes and sends the command using an enriched wire protocol that extracts the correlation id and makes command metadata
- The corresponding command handler deserializes the command and embeds the metadata in the fiber
- The enriched event handler extracts the metadata from the fiber and put the correlation id into the event metadata
Reference: https://blog.softwaremill.com/correlation-ids-in-scala-using-monix-3aa11783db81
Metadata
Metadata
Assignees
Labels
No labels