Documentation
¶
Overview ¶
Package parcel provides a high-level container for messages and their envelopes.
Index ¶
- type Packer
- func (p *Packer) PackChildCommand(c Parcel, m dogma.Command, handler *envelopespec.Identity, instanceID string) Parcel
- func (p *Packer) PackChildEvent(c Parcel, m dogma.Event, handler *envelopespec.Identity, instanceID string) Parcel
- func (p *Packer) PackChildTimeout(c Parcel, m dogma.Timeout, t time.Time, handler *envelopespec.Identity, ...) Parcel
- func (p *Packer) PackCommand(m dogma.Command) Parcel
- func (p *Packer) PackEvent(m dogma.Event) Parcel
- type Parcel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Packer ¶
type Packer struct {
// Application is the identity of this application.
Application *envelopespec.Identity
// Marshaler is used to marshal messages into envelopes.
Marshaler marshaler.Marshaler
// Produced is the set of message types that are produced by this
// application.
Produced *sets.Set[message.Type]
// Consumed is the set of message types that are consumed by this
// application.
Consumed *sets.Set[message.Type]
// GenerateID is a function used to generate new message IDs. If it is nil,
// a UUID is generated.
GenerateID func() string
// Now is a function used to get the current time. If it is nil, time.Now()
// is used.
Now func() time.Time
}
Packer puts messages into parcels.
func (*Packer) PackChildCommand ¶
func (p *Packer) PackChildCommand( c Parcel, m dogma.Command, handler *envelopespec.Identity, instanceID string, ) Parcel
PackChildCommand returns a parcel containing the given command message, configured as a child of c, the cause.
func (*Packer) PackChildEvent ¶
func (p *Packer) PackChildEvent( c Parcel, m dogma.Event, handler *envelopespec.Identity, instanceID string, ) Parcel
PackChildEvent returns a parcel containing the given event message, configured as a child of c, the cause.
func (*Packer) PackChildTimeout ¶
func (p *Packer) PackChildTimeout( c Parcel, m dogma.Timeout, t time.Time, handler *envelopespec.Identity, instanceID string, ) Parcel
PackChildTimeout returns a parcel containing the given timeout message, configured as a child of c, the cause.
func (*Packer) PackCommand ¶
PackCommand returns a parcel containing the given command message.
type Parcel ¶
type Parcel struct {
// Envelope is the message envelope.
Envelope *envelopespec.Envelope
// Message is the original representation of the message.
Message dogma.Message
// CreatedAt is the time at which the message was created.
CreatedAt time.Time
// ScheduledFor is the time at which a timeout message is scheduled to
// occur. If the message is not a timeout message it is the zero-value.
ScheduledFor time.Time
}
A Parcel is a container for an envelope and the original information that was used to create it.
func FromEnvelope ¶
FromEnvelope constructs a parcel from an envelope.