Skip to content

Context

Bases: BaseModel

Extensible context object for event metadata.

Designed to carry correlation and causation identifiers, and can be extended with additional metadata fields as needed. This allows for flexible propagation of context information throughout event processing and handling pipelines.

Attributes:

Name Type Description
correlation_id UUID | None

Identifier for correlating related events.

causation_id UUID | None

Identifier for the cause of the event.

Additional fields can be added dynamically due to extra="allow".

Source code in event_sourcery/_event_store/event/dto.py
class Context(BaseModel, extra="allow"):
    """
    Extensible context object for event metadata.

    Designed to carry correlation and causation identifiers, and can be extended
    with additional metadata fields as needed. This allows for flexible propagation
    of context information throughout event processing and handling pipelines.

    Attributes:
        correlation_id (UUID | None): Identifier for correlating related events.
        causation_id (UUID | None): Identifier for the cause of the event.

    Additional fields can be added dynamically due to `extra="allow"`.
    """

    correlation_id: UUID | None = None
    causation_id: UUID | None = None