Documentation
¶
Overview ¶
Package shell provides conversion functions between domain events and storable events for the example: Book circulation in a public library
This package implements the "imperative shell" pattern, handling the translation between the functional core (domain events) and the external storage layer (storable events). It manages event serialization, deserialization, and metadata handling for the event sourcing system.
In Domain-Driven Design or Hexagonal Architecture terminology, this would be called the 'infrastructure' layer.
Index ¶
- Variables
- func DomainEventFrom(storableEvent eventstore.StorableEvent) (core.DomainEvent, error)
- func DomainEventsFrom(storableEvents eventstore.StorableEvents) (core.DomainEvents, error)
- func StorableEventFrom(event core.DomainEvent, metadata EventMetadata) (eventstore.StorableEvent, error)
- func StorableEventWithEmptyMetadataFrom(event core.DomainEvent) (eventstore.StorableEvent, error)
- type CausationID
- type CorrelationID
- type EventMetadata
- type MessageID
- type TimingCollector
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMappingToDomainEventFailed is returned when domain event conversion fails. ErrMappingToDomainEventFailed = errors.New("mapping to domain event failed") // ErrMappingToDomainEventUnknownEventType is returned for unrecognized event types. ErrMappingToDomainEventUnknownEventType = errors.New("unknown event type") )
var ErrMappingToEventMetadataFailed = errors.New("mapping to event metadata failed")
ErrMappingToEventMetadataFailed is returned when metadata conversion fails.
var ErrMappingToStorableEventFailedForDomainEvent = errors.New("mapping to storable event failed for domain event")
ErrMappingToStorableEventFailedForDomainEvent is returned when domain event serialization fails.
var ErrMappingToStorableEventFailedForMetadata = errors.New("mapping to storable event failed for metadata")
ErrMappingToStorableEventFailedForMetadata is returned when metadata serialization fails.
Functions ¶
func DomainEventFrom ¶
func DomainEventFrom(storableEvent eventstore.StorableEvent) (core.DomainEvent, error)
DomainEventFrom converts a StorableEvent to its corresponding DomainEvent.
func DomainEventsFrom ¶
func DomainEventsFrom(storableEvents eventstore.StorableEvents) (core.DomainEvents, error)
DomainEventsFrom converts multiple StorableEvents to DomainEvents.
func StorableEventFrom ¶
func StorableEventFrom(event core.DomainEvent, metadata EventMetadata) (eventstore.StorableEvent, error)
StorableEventFrom converts a DomainEvent and EventMetadata to a StorableEvent.
func StorableEventWithEmptyMetadataFrom ¶
func StorableEventWithEmptyMetadataFrom(event core.DomainEvent) (eventstore.StorableEvent, error)
StorableEventWithEmptyMetadataFrom converts a DomainEvent to a StorableEvent with empty metadata.
Types ¶
type CausationID ¶
type CausationID = string
CausationID represents the ID of the event that caused this event.
type CorrelationID ¶
type CorrelationID = string
CorrelationID represents the ID correlating related events.
type EventMetadata ¶
type EventMetadata struct { MessageID MessageID CausationID CausationID CorrelationID CorrelationID }
EventMetadata contains event tracking information.
func BuildEventMetadata ¶
func BuildEventMetadata(messageID uuid.UUID, causationID uuid.UUID, correlationID uuid.UUID) EventMetadata
BuildEventMetadata creates EventMetadata from UUID values.
func EventMetadataFrom ¶
func EventMetadataFrom(storableEvent eventstore.StorableEvent) (EventMetadata, error)
EventMetadataFrom extracts EventMetadata from a StorableEvent.
type TimingCollector ¶
type TimingCollector struct { QueryTime *time.Duration UnmarshalTime *time.Duration BusinessTime *time.Duration AppendTime *time.Duration }
TimingCollector collects timing measurements during benchmark operations for detailed performance analysis.
func NewTimingCollector ¶
func NewTimingCollector(queryTime, unmarshalTime, businessTime, appendTime *time.Duration) TimingCollector
NewTimingCollector creates a new TimingCollector with pointers to duration variables that will accumulate timing measurements.
func (TimingCollector) RecordAppend ¶
func (t TimingCollector) RecordAppend(duration time.Duration)
RecordAppend records event appending time.
func (TimingCollector) RecordBusiness ¶
func (t TimingCollector) RecordBusiness(duration time.Duration)
RecordBusiness records business logic execution time.
func (TimingCollector) RecordQuery ¶
func (t TimingCollector) RecordQuery(duration time.Duration)
RecordQuery records database query execution time.
func (TimingCollector) RecordUnmarshal ¶
func (t TimingCollector) RecordUnmarshal(duration time.Duration)
RecordUnmarshal records event unmarshaling time.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package config provides database configuration helpers for PostgreSQL connections for the example: Book circulation in a public library
|
Package config provides database configuration helpers for PostgreSQL connections for the example: Book circulation in a public library |