Documentation
¶
Index ¶
Constants ¶
const ( MetaCorrelationID = "eventuous.correlation-id" MetaCausationID = "eventuous.causation-id" MetaMessageID = "eventuous.message-id" )
Well-known metadata key constants.
Variables ¶
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 ¶
Metadata carries event metadata such as correlation and causation identifiers as well as arbitrary custom headers.
func (Metadata) CausationID ¶
CausationID returns the causation ID stored in the metadata, or an empty string if it is not set.
func (Metadata) CorrelationID ¶
CorrelationID returns the correlation ID stored in the metadata, or an empty string if it is not set.
func (Metadata) WithCausationID ¶
WithCausationID returns a new Metadata with the given causation ID set. The original Metadata is not modified.
func (Metadata) WithCorrelationID ¶
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.