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.Message, handler *envelopespec.Identity, instanceID string) Parcel
- func (p *Packer) PackChildEvent(c Parcel, m dogma.Message, handler *envelopespec.Identity, instanceID string) Parcel
- func (p *Packer) PackChildTimeout(c Parcel, m dogma.Message, t time.Time, handler *envelopespec.Identity, ...) Parcel
- func (p *Packer) PackCommand(m dogma.Message) Parcel
- func (p *Packer) PackEvent(m dogma.Message) 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 marshalkit.ValueMarshaler // Produced is a map of message type to role, used to validate the messages // that are being packed. Produced message.TypeRoles // Consumed is a map of message type to role for consumed messages, which // can be the cause of new messages. Consumed message.TypeRoles // 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.Message, 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.Message, 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.Message, 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 ¶
func FromEnvelope( ma marshalkit.ValueMarshaler, env *envelopespec.Envelope, ) (Parcel, error)
FromEnvelope constructs a parcel from an envelope.