Documentation
¶
Index ¶
- func EventTypeOf(e any) (string, error)
- func FromESEvent(pe es.PersistedEvent) (any, error)
- func FromESEvents[T any](events []es.PersistedEvent) ([]T, error)
- func FromUserDeletedV1(pe es.PersistedEvent) (v1.UserDeleted, error)
- func FromUserEmailChangedV1(pe es.PersistedEvent) (v1.UserEmailChanged, error)
- func FromUserRegisteredV1(pe es.PersistedEvent) (v1.UserRegistered, error)
- func FromUserRegisteredV2(pe es.PersistedEvent) (v2.UserRegistered, error)
- func ToESEvents[T any](boundedContext string, aggregateType string, aggregateID string, events []T, ...) ([]es.Event, error)
- func ToUserDeletedV1(boundedContext string, aggregateType string, aggregateID string, ...) (es.Event, error)
- func ToUserEmailChangedV1(boundedContext string, aggregateType string, aggregateID string, ...) (es.Event, error)
- func ToUserRegisteredV1(boundedContext string, aggregateType string, aggregateID string, ...) (es.Event, error)
- func ToUserRegisteredV2(boundedContext string, aggregateType string, aggregateID string, ...) (es.Event, error)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EventTypeOf ¶
EventTypeOf returns the event type string for a given domain event. The event type is the struct name without version information.
func FromESEvent ¶
func FromESEvent(pe es.PersistedEvent) (any, error)
FromESEvent converts a single persisted event to a domain event. This is useful for projection handlers that need to convert individual events.
func FromESEvents ¶
func FromESEvents[T any](events []es.PersistedEvent) ([]T, error)
FromESEvents converts persisted events back to domain events. The function uses generics to return a strongly-typed slice. T must be 'any' or a common interface implemented by all domain events.
func FromUserDeletedV1 ¶
func FromUserDeletedV1(pe es.PersistedEvent) (v1.UserDeleted, error)
FromUserDeletedV1 converts a persisted event to a domain event. Returns an error if the event type or version doesn't match.
func FromUserEmailChangedV1 ¶
func FromUserEmailChangedV1(pe es.PersistedEvent) (v1.UserEmailChanged, error)
FromUserEmailChangedV1 converts a persisted event to a domain event. Returns an error if the event type or version doesn't match.
func FromUserRegisteredV1 ¶
func FromUserRegisteredV1(pe es.PersistedEvent) (v1.UserRegistered, error)
FromUserRegisteredV1 converts a persisted event to a domain event. Returns an error if the event type or version doesn't match.
func FromUserRegisteredV2 ¶
func FromUserRegisteredV2(pe es.PersistedEvent) (v2.UserRegistered, error)
FromUserRegisteredV2 converts a persisted event to a domain event. Returns an error if the event type or version doesn't match.
func ToESEvents ¶
func ToESEvents[T any](boundedContext string, aggregateType string, aggregateID string, events []T, opts ...Option) ([]es.Event, error)
ToESEvents converts domain events to es.Event instances. Each domain event is marshaled to JSON and wrapped in an es.Event. The generic type T allows for type-safe event slices instead of []any.
func ToUserDeletedV1 ¶
func ToUserDeletedV1(boundedContext string, aggregateType string, aggregateID string, e v1.UserDeleted, opts ...Option) (es.Event, error)
ToUserDeletedV1 converts a domain event to an es.Event.
func ToUserEmailChangedV1 ¶
func ToUserEmailChangedV1(boundedContext string, aggregateType string, aggregateID string, e v1.UserEmailChanged, opts ...Option) (es.Event, error)
ToUserEmailChangedV1 converts a domain event to an es.Event.
Types ¶
type Option ¶
type Option func(*eventOptions)
Option is a functional option for configuring event metadata.
func WithCausationID ¶
WithCausationID sets the causation ID for the event.
func WithCorrelationID ¶
WithCorrelationID sets the correlation ID for the event.
func WithMetadata ¶
WithMetadata sets custom metadata for the event.