Help us shape the future of Go! Take the 2026 Go Developer Survey

envelope

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package envelope provides a container for passing Dogma messages and their meta-data between components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	// MessageID is a unique identifier for the message.
	MessageID string

	// CausationID is the ID of the message that was being handled when the
	// message identified by MessageID was produced.
	CausationID string

	// CorrelationID is the ID of the "root" message that entered the
	// application to cause the message identified by MessageID, either directly
	// or indirectly.
	CorrelationID string

	// Message is the application-defined message that the envelope represents.
	Message dogma.Message

	// CreatedAt is the time at which the message was created.
	CreatedAt time.Time

	// ScheduledFor holds the time for which a deadline message is scheduled.
	// Its value is undefined for commands and events.
	ScheduledFor time.Time

	// Origin describes the message handler that produced this message.
	// It is nil if the message was not produced by a handler.
	Origin *Origin

	// EventStreamID is the ID of the event stream to which this message
	// belongs, if it is a [dogma.Event].
	EventStreamID string

	// EventStreamOffset is the offset of the message within its event stream.
	EventStreamOffset uint64
}

Envelope is a container for a message that is handled by the test engine.

func NewCommand

func NewCommand(
	id string,
	m dogma.Command,
	t time.Time,
) *Envelope

NewCommand constructs a new envelope containing the given command message.

t is the time at which the message was created.

func NewEvent

func NewEvent(
	id string,
	m dogma.Event,
	t time.Time,
) *Envelope

NewEvent constructs a new envelope containing the given event message.

t is the time at which the message was created.

func (*Envelope) NewCommand

func (e *Envelope) NewCommand(
	id string,
	m dogma.Command,
	t time.Time,
	o Origin,
) *Envelope

NewCommand constructs a new envelope as a child of e, indicating that the command message m is caused by e.Message.

t is the time at which the message was created.

func (*Envelope) NewDeadline added in v0.22.0

func (e *Envelope) NewDeadline(
	id string,
	m dogma.Deadline,
	t time.Time,
	s time.Time,
	o Origin,
) *Envelope

NewDeadline constructs a new envelope as a child of e, indicating that the deadline message m is caused by e.Message.

t is the time at which the message was created. s is the time for which the deadline is scheduled.

func (*Envelope) NewEvent

func (e *Envelope) NewEvent(
	id string,
	m dogma.Event,
	t time.Time,
	o Origin,
	streamID string,
	offset uint64,
) *Envelope

NewEvent constructs a new envelope as a child of e, indicating that the event message m is caused by e.Message.

t is the time at which the message was created.

type MessageIDGenerator

type MessageIDGenerator struct {
	// contains filtered or unexported fields
}

MessageIDGenerator produces sequential message IDs.

func (*MessageIDGenerator) Next

func (g *MessageIDGenerator) Next() string

Next returns the next ID in the sequence.

func (*MessageIDGenerator) Reset

func (g *MessageIDGenerator) Reset()

Reset resets the generator to begin at one (1) again.

type Origin

type Origin struct {
	// Handler is the handler that produced this message.
	Handler config.Handler

	// HandlerType is the type of the handler that produced this message.
	HandlerType config.HandlerType

	// InstanceID is the ID of the aggregate or process instance that produced
	// this message.
	//
	// It is empty if HandlerType is neither [config.AggregateHandlerType] nor
	// [config.ProcessHandlerType].
	InstanceID string
}

Origin describes the handler that produced a message in an envelope.

Jump to

Keyboard shortcuts

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