shell

package
v1.1.4-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var ErrMappingToDomainEventFailed = errors.New("mapping to domain event failed")

ErrMappingToDomainEventFailed is returned when domain event conversion fails

View Source
var ErrMappingToDomainEventUnknownEventType = errors.New("unknown event type")

ErrMappingToDomainEventUnknownEventType is returned for unrecognized event types

View Source
var ErrMappingToEventMetadataFailed = errors.New("mapping to event metadata failed")

ErrMappingToEventMetadataFailed is returned when metadata conversion fails

View Source
var ErrMappingToStorableEventFailedForDomainEvent = errors.New("mapping to storable event failed for domain event")

ErrMappingToStorableEventFailedForDomainEvent is returned when domain event serialization fails

View Source
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 MessageID

type MessageID = string

MessageID represents a unique message identifier

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL