Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow to enrich a command as well as an event #74

@guersam

Description

@guersam

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:

  1. A http4s middleware generates a correlation id, and embeds it in the fiber (effect context) using TaskLocal/FiberRef
  2. The Aecor runtime serializes and sends the command using an enriched wire protocol that extracts the correlation id and makes command metadata
  3. The corresponding command handler deserializes the command and embeds the metadata in the fiber
  4. 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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions