Documentation ¶
Overview ¶
Package envelope contains tools for working with message envelopes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PackOption ¶
type PackOption func(*envelopepb.Envelope)
PackOption is an option that alters the behavior of a Pack operation.
func WithCause ¶
func WithCause(env *envelopepb.Envelope) PackOption
WithCause sets env as the "cause" of the message being packed.
func WithCreatedAt ¶
func WithCreatedAt(t time.Time) PackOption
WithCreatedAt sets the creation time of a message.
func WithHandler ¶
func WithHandler(h *identitypb.Identity) PackOption
WithHandler sets h as the identity of the handler that is the source of the message.
func WithInstanceID ¶
func WithInstanceID(id string) PackOption
WithInstanceID sets the aggregate or process instance ID that is the source of the message.
func WithScheduledFor ¶
func WithScheduledFor(t time.Time) PackOption
WithScheduledFor sets the scheduled time of a timeout message.
type Packer ¶
type Packer struct { // Site is the (optional) identity of the site that the source application // is running within. // // The site is used to disambiguate between messages from different // installations of the same application. Site *identitypb.Identity // Application is the identity of the application that is the source of the // messages. Application *identitypb.Identity // Marshaler is used to marshal messages into envelopes. Marshaler marshalkit.ValueMarshaler // GenerateID is a function used to generate new message IDs. If it is nil, // a UUID is generated. GenerateID func() *uuidpb.UUID // Now is a function used to get the current time. If it is nil, time.Now() // is used. Now func() time.Time }
A Packer puts messages into envelopes.
func (*Packer) Pack ¶
func (p *Packer) Pack( m dogma.Message, options ...PackOption, ) *envelopepb.Envelope
Pack returns an envelope containing the given message.
type Transcoder ¶
type Transcoder struct { // MediaTypes is a map of the message's "portable name" to a list of // supported media-types, in order of preference. MediaTypes map[string][]string // Marshaler is the marshaler to use to unmarshal and marshal messages. Marshaler marshalkit.Marshaler }
Transcoder re-encodes messages to different media-types on the fly.
func (*Transcoder) Transcode ¶
func (t *Transcoder) Transcode(env *envelopepb.Envelope) (*envelopepb.Envelope, bool, error)
Transcode re-encodes the message in env to one of the supported media-types.