eventuous

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MetaCorrelationID = "eventuous.correlation-id"
	MetaCausationID   = "eventuous.causation-id"
	MetaMessageID     = "eventuous.message-id"
)

Well-known metadata key constants.

Variables

View Source
var (
	// ErrStreamNotFound is returned when a requested stream does not exist.
	ErrStreamNotFound = errors.New("eventuous: stream not found")
	// ErrOptimisticConcurrency is returned when an append fails due to a
	// version mismatch.
	ErrOptimisticConcurrency = errors.New("eventuous: wrong expected version")
	// ErrAggregateNotFound is returned when an aggregate cannot be loaded.
	ErrAggregateNotFound = errors.New("eventuous: aggregate not found")
	// ErrHandlerNotFound is returned when no handler is registered for a command.
	ErrHandlerNotFound = errors.New("eventuous: command handler not found")
)

Sentinel errors returned by eventuous operations.

Functions

This section is empty.

Types

type ExpectedState

type ExpectedState int

ExpectedState controls how a command service loads existing state before executing a command.

const (
	// IsNew requires the stream to not yet exist.
	IsNew ExpectedState = iota
	// IsExisting requires the stream to already exist.
	IsExisting
	// IsAny allows the stream to either exist or not.
	IsAny
)

type ExpectedVersion

type ExpectedVersion int64

ExpectedVersion is used for optimistic concurrency control when appending events to a stream.

const (
	// VersionNoStream indicates the stream must not exist when appending.
	VersionNoStream ExpectedVersion = -1
	// VersionAny disables optimistic concurrency checks entirely.
	VersionAny ExpectedVersion = -2
)

type Metadata

type Metadata map[string]any

Metadata carries event metadata such as correlation and causation identifiers as well as arbitrary custom headers.

func (Metadata) CausationID

func (m Metadata) CausationID() string

CausationID returns the causation ID stored in the metadata, or an empty string if it is not set.

func (Metadata) CorrelationID

func (m Metadata) CorrelationID() string

CorrelationID returns the correlation ID stored in the metadata, or an empty string if it is not set.

func (Metadata) WithCausationID

func (m Metadata) WithCausationID(id string) Metadata

WithCausationID returns a new Metadata with the given causation ID set. The original Metadata is not modified.

func (Metadata) WithCorrelationID

func (m Metadata) WithCorrelationID(id string) Metadata

WithCorrelationID returns a new Metadata with the given correlation ID set. The original Metadata is not modified.

type StreamName

type StreamName string

StreamName is a typed string representing an event stream, following the "{Category}-{ID}" naming convention used by Eventuous.

func NewStreamName

func NewStreamName(category, id string) StreamName

NewStreamName creates a StreamName from a category and an ID, joining them with a "-" separator.

func (StreamName) Category

func (s StreamName) Category() string

Category returns the part of the stream name before the first "-". If there is no "-", the entire name is returned as the category.

func (StreamName) ID

func (s StreamName) ID() string

ID returns the part of the stream name after the first "-". If there is no "-", an empty string is returned.

func (StreamName) String

func (s StreamName) String() string

String returns the underlying string value of the StreamName.

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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