shared

package
v1.4.1-beta Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package shared provides EventStore interfaces and common types for testing.

This package defines the QueriesAndAppendsEvents interface that abstracts EventStore operations for test helpers, enabling test utilities to work with any EventStore implementation (PostgreSQL, future backends) without tight coupling.

Key components:

  • QueriesAndAppendsEvents: Interface for essential EventStore operations
  • DomainEvent: Common interface for domain events
  • Event metadata utilities for test setup

This enables EventStore-agnostic test helpers in estesthelpers package.

Index

Constants

This section is empty.

Variables

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

ErrMappingToEventMetadataFailed is returned when metadata conversion fails.

Functions

This section is empty.

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 DomainEvent

type DomainEvent interface {
	// IsEventType HasEventType returns the string identifier for this event type.
	IsEventType() string

	// HasOccurredAt returns when this event occurred.
	HasOccurredAt() time.Time

	// IsErrorEvent returns true if this event represents an error or failure condition.
	IsErrorEvent() bool
}

DomainEvent represents a business event that has occurred in the domain.

type DomainEvents

type DomainEvents = []DomainEvent

DomainEvents is a slice of DomainEvent instances.

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.

type QueriesAndAppendsEvents

type QueriesAndAppendsEvents interface {
	Query(ctx context.Context, filter eventstore.Filter) (eventstore.StorableEvents, eventstore.MaxSequenceNumberUint, error)
	Append(ctx context.Context, filter eventstore.Filter, maxSeq eventstore.MaxSequenceNumberUint, events ...eventstore.StorableEvent) error
}

QueriesAndAppendsEvents abstracts EventStore operations for test helpers. This interface enables test utilities to work with any EventStore implementation (PostgreSQL, future backends) by providing the essential query and append operations needed for test setup and verification.

Jump to

Keyboard shortcuts

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