Documentation
¶
Overview ¶
Package envelope provides a container for passing Dogma messages and their meta-data between components.
Index ¶
- type Envelope
- func (e *Envelope) NewCommand(id string, m dogma.Command, t time.Time, o Origin) *Envelope
- func (e *Envelope) NewEvent(id string, m dogma.Event, t time.Time, o Origin, streamID string, ...) *Envelope
- func (e *Envelope) NewTimeout(id string, m dogma.Timeout, t time.Time, s time.Time, o Origin) *Envelope
- type MessageIDGenerator
- type Origin
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 at which a timeout message is scheduled to
// occur. 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 ¶
NewCommand constructs a new envelope containing the given command message.
t is the time at which the message was created.
func NewEvent ¶
NewEvent constructs a new envelope containing the given event message.
t is the time at which the message was created.
func (*Envelope) NewCommand ¶
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) 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.
func (*Envelope) NewTimeout ¶
func (e *Envelope) NewTimeout( id string, m dogma.Timeout, t time.Time, s time.Time, o Origin, ) *Envelope
NewTimeout constructs a new envelope as a child of e, indicating that the timeout message m is caused by e.Message.
t is the time at which the message was created. s is the time at which the timeout is scheduled to occur.
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.