envelopepb

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 14 Imported by: 2

Documentation

Overview

Package envelopepb provides the "well-known" Envelope type for representing message envelopes as Protocol Buffers messages.

Index

Constants

This section is empty.

Variables

View Source
var File_github_com_dogmatiq_enginekit_protobuf_envelopepb_envelope_proto protoreflect.FileDescriptor

Functions

func Unpack added in v0.19.0

func Unpack(env *Envelope) (dogma.Message, error)

Unpack returns the message contained within an envelope. TODO: Make `UnpackCommand`, etc.

func WithBaggage added in v0.22.0

WithBaggage adds x to the envelope's baggage.

Baggage applies to the envelope being packed and is inherited by downstream messages in the causal chain.

func WithExtension added in v0.22.0

WithExtension adds x to the envelope's extensions.

Extensions apply only to the envelope being packed; they are not inherited by downstream messages in the causal chain.

Types

type Body added in v0.21.0

type Body struct {

	// MessageId is a unique identifier for the message in this envelope.
	MessageId *uuidpb.UUID `protobuf:"bytes,1,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"`
	// IdempotencyKey is an application-defined value used to identify a command
	// across retries.
	//
	// It is the zero-value if the message is not a command, or if the producer
	// of the message did not provide an idempotency key.
	IdempotencyKey string `protobuf:"bytes,2,opt,name=idempotency_key,json=idempotencyKey,proto3" json:"idempotency_key,omitempty"`
	// CreatedAt is the time at which the envelope was created.
	//
	// This is typically the point at which the message first enters the engine.
	CreatedAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	// ScheduledFor is the time at which a timeout message is scheduled to occur.
	//
	// It is the zero-value if the message is a command or event.
	ScheduledFor *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=scheduled_for,json=scheduledFor,proto3" json:"scheduled_for,omitempty"`
	// Message is the encoded representation of the [dogma.Message].
	Message *Message `protobuf:"bytes,5,opt,name=message,proto3" json:"message,omitempty"`
	// Extensions is a set of extension values associated with this message.
	//
	// Any values in [Header.Extensions] are overridden by values in this field
	// that have the same type URL.
	Extensions []*anypb.Any `protobuf:"bytes,6,rep,name=extensions,proto3" json:"extensions,omitempty"`
	// Baggage is a set of extension values associated with this message and/or
	// its causal chain.
	//
	// Any values in [Header.Baggage] are overridden by values in this field
	// that have the same type URL.
	Baggage []*anypb.Any `protobuf:"bytes,7,rep,name=baggage,proto3" json:"baggage,omitempty"`
	// contains filtered or unexported fields
}

Body contains the metadata and encoded form of a single message in an Envelope or MultiEnvelope.

func (*Body) Descriptor deprecated added in v0.21.0

func (*Body) Descriptor() ([]byte, []int)

Deprecated: Use Body.ProtoReflect.Descriptor instead.

func (*Body) GetBaggage added in v0.22.0

func (x *Body) GetBaggage() []*anypb.Any

func (*Body) GetCreatedAt added in v0.21.0

func (x *Body) GetCreatedAt() *timestamppb.Timestamp

func (*Body) GetExtensions added in v0.21.0

func (x *Body) GetExtensions() []*anypb.Any

func (*Body) GetIdempotencyKey added in v0.21.0

func (x *Body) GetIdempotencyKey() string

func (*Body) GetMessage added in v0.21.0

func (x *Body) GetMessage() *Message

func (*Body) GetMessageId added in v0.21.0

func (x *Body) GetMessageId() *uuidpb.UUID

func (*Body) GetScheduledFor added in v0.21.0

func (x *Body) GetScheduledFor() *timestamppb.Timestamp

func (*Body) MarshalBinary added in v0.21.0

func (x *Body) MarshalBinary() ([]byte, error)

MarshalBinary returns the binary representation of the message, equivalent to calling proto.Marshal(x).

It allows *Body to implement encoding.BinaryMarshaler.

func (*Body) ProtoMessage added in v0.21.0

func (*Body) ProtoMessage()

func (*Body) ProtoReflect added in v0.21.0

func (x *Body) ProtoReflect() protoreflect.Message

func (*Body) Reset added in v0.21.0

func (x *Body) Reset()

func (*Body) SetBaggage added in v0.22.0

func (x *Body) SetBaggage(v []*anypb.Any)

SetBaggage sets the x.Baggage field to v, then returns x.

func (*Body) SetCreatedAt added in v0.21.0

func (x *Body) SetCreatedAt(v *timestamppb.Timestamp)

SetCreatedAt sets the x.CreatedAt field to v, then returns x.

func (*Body) SetExtensions added in v0.21.0

func (x *Body) SetExtensions(v []*anypb.Any)

SetExtensions sets the x.Extensions field to v, then returns x.

func (*Body) SetIdempotencyKey added in v0.21.0

func (x *Body) SetIdempotencyKey(v string)

SetIdempotencyKey sets the x.IdempotencyKey field to v, then returns x.

func (*Body) SetMessage added in v0.21.0

func (x *Body) SetMessage(v *Message)

SetMessage sets the x.Message field to v, then returns x.

func (*Body) SetMessageId added in v0.21.0

func (x *Body) SetMessageId(v *uuidpb.UUID)

SetMessageId sets the x.MessageId field to v, then returns x.

func (*Body) SetScheduledFor added in v0.21.0

func (x *Body) SetScheduledFor(v *timestamppb.Timestamp)

SetScheduledFor sets the x.ScheduledFor field to v, then returns x.

func (*Body) String added in v0.21.0

func (x *Body) String() string

func (*Body) UnmarshalBinary added in v0.21.0

func (x *Body) UnmarshalBinary(data []byte) error

UnmarshalBinary populates x from its binary representation, equivalent to calling proto.Unmarshal(data, x).

It allows *Body to implement encoding.BinaryUnmarshaler.

type BodyBuilder added in v0.21.0

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

func NewBodyBuilder added in v0.21.0

func NewBodyBuilder() *BodyBuilder

NewBodyBuilder returns a builder that constructs Body messages.

func (*BodyBuilder) Build added in v0.21.0

func (b *BodyBuilder) Build() *Body

Build returns a new Body containing the values configured via the builder.

Each call returns a new message, such that future changes to the builder do not modify previously constructed messages.

func (*BodyBuilder) From added in v0.21.0

func (b *BodyBuilder) From(x *Body) *BodyBuilder

From configures the builder to use x as the prototype for new messages, then returns b.

It performs a shallow copy of x, such that any changes made via the builder do not modify x. It does not make a copy of the field values themselves.

func (*BodyBuilder) WithBaggage added in v0.22.0

func (b *BodyBuilder) WithBaggage(v []*anypb.Any) *BodyBuilder

WithBaggage configures the builder to set the Baggage field to v, then returns b.

func (*BodyBuilder) WithCreatedAt added in v0.21.0

func (b *BodyBuilder) WithCreatedAt(v *timestamppb.Timestamp) *BodyBuilder

WithCreatedAt configures the builder to set the CreatedAt field to v, then returns b.

func (*BodyBuilder) WithExtensions added in v0.21.0

func (b *BodyBuilder) WithExtensions(v []*anypb.Any) *BodyBuilder

WithExtensions configures the builder to set the Extensions field to v, then returns b.

func (*BodyBuilder) WithIdempotencyKey added in v0.21.0

func (b *BodyBuilder) WithIdempotencyKey(v string) *BodyBuilder

WithIdempotencyKey configures the builder to set the IdempotencyKey field to v, then returns b.

func (*BodyBuilder) WithMessage added in v0.21.0

func (b *BodyBuilder) WithMessage(v *Message) *BodyBuilder

WithMessage configures the builder to set the Message field to v, then returns b.

func (*BodyBuilder) WithMessageId added in v0.21.0

func (b *BodyBuilder) WithMessageId(v *uuidpb.UUID) *BodyBuilder

WithMessageId configures the builder to set the MessageId field to v, then returns b.

func (*BodyBuilder) WithScheduledFor added in v0.21.0

func (b *BodyBuilder) WithScheduledFor(v *timestamppb.Timestamp) *BodyBuilder

WithScheduledFor configures the builder to set the ScheduledFor field to v, then returns b.

type EffectPacker added in v0.22.0

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

An EffectPacker packs messages produced while handling a specific causal message into a MultiEnvelope.

func (*EffectPacker) PackCommand added in v0.22.0

func (p *EffectPacker) PackCommand(m dogma.Command, options ...PackEffectCommandOption)

PackCommand appends m to the multi-envelope under construction.

func (*EffectPacker) PackEvent added in v0.22.0

func (p *EffectPacker) PackEvent(m dogma.Event, options ...PackEffectEventOption)

PackEvent appends m to the multi-envelope under construction.

func (*EffectPacker) PackTimeout added in v0.22.0

func (p *EffectPacker) PackTimeout(m dogma.Timeout, options ...PackEffectTimeoutOption)

PackTimeout appends m to the multi-envelope under construction.

func (*EffectPacker) Seal added in v0.22.0

func (p *EffectPacker) Seal() (*MultiEnvelope, bool)

Seal returns a MultiEnvelope containing all packed messages, or false if no messages were packed.

type Envelope

type Envelope struct {
	Header *Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"`
	Body   *Body   `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"`
	// contains filtered or unexported fields
}

Envelope is a container for a Dogma message and its meta-data.

It is wire-compatible with MultiEnvelope.

func (*Envelope) Descriptor deprecated

func (*Envelope) Descriptor() ([]byte, []int)

Deprecated: Use Envelope.ProtoReflect.Descriptor instead.

func (*Envelope) GetBody added in v0.21.0

func (x *Envelope) GetBody() *Body

func (*Envelope) GetHeader added in v0.21.0

func (x *Envelope) GetHeader() *Header

func (*Envelope) MarshalBinary added in v0.18.0

func (x *Envelope) MarshalBinary() ([]byte, error)

MarshalBinary returns the binary representation of the message, equivalent to calling proto.Marshal(x).

It allows *Envelope to implement encoding.BinaryMarshaler.

func (*Envelope) ProtoMessage

func (*Envelope) ProtoMessage()

func (*Envelope) ProtoReflect

func (x *Envelope) ProtoReflect() protoreflect.Message

func (*Envelope) Reset

func (x *Envelope) Reset()

func (*Envelope) SetBody added in v0.21.0

func (x *Envelope) SetBody(v *Body)

SetBody sets the x.Body field to v, then returns x.

func (*Envelope) SetHeader added in v0.21.0

func (x *Envelope) SetHeader(v *Header)

SetHeader sets the x.Header field to v, then returns x.

func (*Envelope) String

func (x *Envelope) String() string

func (*Envelope) UnmarshalBinary added in v0.18.0

func (x *Envelope) UnmarshalBinary(data []byte) error

UnmarshalBinary populates x from its binary representation, equivalent to calling proto.Unmarshal(data, x).

It allows *Envelope to implement encoding.BinaryUnmarshaler.

func (*Envelope) Validate

func (x *Envelope) Validate() error

Validate returns an error if x is not well-formed.

Well-formedness means that all compulsory fields are populated and that no incompatible fields are populated.

It is intentionally fairly permissive, so that message meta-data can be obtained even if the message is unable to be handled.

It does not perform "deep" validation, such as ensuring messages, times, etc can be unmarshaled.

type EnvelopeBuilder

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

func NewEnvelopeBuilder

func NewEnvelopeBuilder() *EnvelopeBuilder

NewEnvelopeBuilder returns a builder that constructs Envelope messages.

func (*EnvelopeBuilder) Build

func (b *EnvelopeBuilder) Build() *Envelope

Build returns a new Envelope containing the values configured via the builder.

Each call returns a new message, such that future changes to the builder do not modify previously constructed messages.

func (*EnvelopeBuilder) From

From configures the builder to use x as the prototype for new messages, then returns b.

It performs a shallow copy of x, such that any changes made via the builder do not modify x. It does not make a copy of the field values themselves.

func (*EnvelopeBuilder) WithBody added in v0.21.0

func (b *EnvelopeBuilder) WithBody(v *Body) *EnvelopeBuilder

WithBody configures the builder to set the Body field to v, then returns b.

func (*EnvelopeBuilder) WithHeader added in v0.21.0

func (b *EnvelopeBuilder) WithHeader(v *Header) *EnvelopeBuilder

WithHeader configures the builder to set the Header field to v, then returns b.

type Header struct {

	// CausationId is the (optional) ID of the message that was the direct cause
	// of the messages.
	//
	// If it is the zero-value, the messages were not caused by any other
	// message.
	CausationId *uuidpb.UUID `protobuf:"bytes,1,opt,name=causation_id,json=causationId,proto3" json:"causation_id,omitempty"`
	// CorrelationId is the (optional) ID of the first ancestor of the messages
	// that was itself not caused by another message, that is, it's the root of
	// the message chain that ultimately resulted in these messages.
	//
	// If it is the zero-value, the messages were not caused by any other
	// message.
	CorrelationId *uuidpb.UUID `protobuf:"bytes,2,opt,name=correlation_id,json=correlationId,proto3" json:"correlation_id,omitempty"`
	// Source identifies the origin of the messages.
	Source *Source `protobuf:"bytes,3,opt,name=source,proto3" json:"source,omitempty"`
	// Extensions is a set of extension values associated with the messages,
	// their causal chain, or the envelope itself.
	Extensions []*anypb.Any `protobuf:"bytes,4,rep,name=extensions,proto3" json:"extensions,omitempty"`
	// Baggage is a set of extension values that are propagated through the
	// entire causal chain of messages.
	Baggage []*anypb.Any `protobuf:"bytes,5,rep,name=baggage,proto3" json:"baggage,omitempty"`
	// contains filtered or unexported fields
}

func (*Header) Descriptor deprecated added in v0.21.0

func (*Header) Descriptor() ([]byte, []int)

Deprecated: Use Header.ProtoReflect.Descriptor instead.

func (*Header) GetBaggage added in v0.22.0

func (x *Header) GetBaggage() []*anypb.Any

func (*Header) GetCausationId added in v0.21.0

func (x *Header) GetCausationId() *uuidpb.UUID

func (*Header) GetCorrelationId added in v0.21.0

func (x *Header) GetCorrelationId() *uuidpb.UUID

func (*Header) GetExtensions added in v0.21.0

func (x *Header) GetExtensions() []*anypb.Any

func (*Header) GetSource added in v0.21.0

func (x *Header) GetSource() *Source

func (*Header) MarshalBinary added in v0.21.0

func (x *Header) MarshalBinary() ([]byte, error)

MarshalBinary returns the binary representation of the message, equivalent to calling proto.Marshal(x).

It allows *Header to implement encoding.BinaryMarshaler.

func (*Header) ProtoMessage added in v0.21.0

func (*Header) ProtoMessage()

func (*Header) ProtoReflect added in v0.21.0

func (x *Header) ProtoReflect() protoreflect.Message

func (*Header) Reset added in v0.21.0

func (x *Header) Reset()

func (*Header) SetBaggage added in v0.22.0

func (x *Header) SetBaggage(v []*anypb.Any)

SetBaggage sets the x.Baggage field to v, then returns x.

func (*Header) SetCausationId added in v0.21.0

func (x *Header) SetCausationId(v *uuidpb.UUID)

SetCausationId sets the x.CausationId field to v, then returns x.

func (*Header) SetCorrelationId added in v0.21.0

func (x *Header) SetCorrelationId(v *uuidpb.UUID)

SetCorrelationId sets the x.CorrelationId field to v, then returns x.

func (*Header) SetExtensions added in v0.21.0

func (x *Header) SetExtensions(v []*anypb.Any)

SetExtensions sets the x.Extensions field to v, then returns x.

func (*Header) SetSource added in v0.21.0

func (x *Header) SetSource(v *Source)

SetSource sets the x.Source field to v, then returns x.

func (*Header) String added in v0.21.0

func (x *Header) String() string

func (*Header) UnmarshalBinary added in v0.21.0

func (x *Header) UnmarshalBinary(data []byte) error

UnmarshalBinary populates x from its binary representation, equivalent to calling proto.Unmarshal(data, x).

It allows *Header to implement encoding.BinaryUnmarshaler.

type HeaderBuilder added in v0.21.0

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

func NewHeaderBuilder added in v0.21.0

func NewHeaderBuilder() *HeaderBuilder

NewHeaderBuilder returns a builder that constructs Header messages.

func (*HeaderBuilder) Build added in v0.21.0

func (b *HeaderBuilder) Build() *Header

Build returns a new Header containing the values configured via the builder.

Each call returns a new message, such that future changes to the builder do not modify previously constructed messages.

func (*HeaderBuilder) From added in v0.21.0

func (b *HeaderBuilder) From(x *Header) *HeaderBuilder

From configures the builder to use x as the prototype for new messages, then returns b.

It performs a shallow copy of x, such that any changes made via the builder do not modify x. It does not make a copy of the field values themselves.

func (*HeaderBuilder) WithBaggage added in v0.22.0

func (b *HeaderBuilder) WithBaggage(v []*anypb.Any) *HeaderBuilder

WithBaggage configures the builder to set the Baggage field to v, then returns b.

func (*HeaderBuilder) WithCausationId added in v0.21.0

func (b *HeaderBuilder) WithCausationId(v *uuidpb.UUID) *HeaderBuilder

WithCausationId configures the builder to set the CausationId field to v, then returns b.

func (*HeaderBuilder) WithCorrelationId added in v0.21.0

func (b *HeaderBuilder) WithCorrelationId(v *uuidpb.UUID) *HeaderBuilder

WithCorrelationId configures the builder to set the CorrelationId field to v, then returns b.

func (*HeaderBuilder) WithExtensions added in v0.21.0

func (b *HeaderBuilder) WithExtensions(v []*anypb.Any) *HeaderBuilder

WithExtensions configures the builder to set the Extensions field to v, then returns b.

func (*HeaderBuilder) WithSource added in v0.21.0

func (b *HeaderBuilder) WithSource(v *Source) *HeaderBuilder

WithSource configures the builder to set the Source field to v, then returns b.

type Message added in v0.21.0

type Message struct {

	// TypeId is a unique identifier for the type of message, as per the Dogma
	// message type registry.
	TypeId *uuidpb.UUID `protobuf:"bytes,1,opt,name=type_id,json=typeId,proto3" json:"type_id,omitempty"`
	// Description is a human-readable description of the message, as returned by
	// the [dogma.Message.MessageDescription] method.
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// Data is the binary message data obtained by calling
	// [dogma.Message.MarshalBinary] on the message.
	Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

Message is the serialized representation of a dogma.Message.

func (*Message) Descriptor deprecated added in v0.21.0

func (*Message) Descriptor() ([]byte, []int)

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) GetData added in v0.21.0

func (x *Message) GetData() []byte

func (*Message) GetDescription added in v0.21.0

func (x *Message) GetDescription() string

func (*Message) GetTypeId added in v0.21.0

func (x *Message) GetTypeId() *uuidpb.UUID

func (*Message) MarshalBinary added in v0.21.0

func (x *Message) MarshalBinary() ([]byte, error)

MarshalBinary returns the binary representation of the message, equivalent to calling proto.Marshal(x).

It allows *Message to implement encoding.BinaryMarshaler.

func (*Message) ProtoMessage added in v0.21.0

func (*Message) ProtoMessage()

func (*Message) ProtoReflect added in v0.21.0

func (x *Message) ProtoReflect() protoreflect.Message

func (*Message) Reset added in v0.21.0

func (x *Message) Reset()

func (*Message) SetData added in v0.21.0

func (x *Message) SetData(v []byte)

SetData sets the x.Data field to v, then returns x.

func (*Message) SetDescription added in v0.21.0

func (x *Message) SetDescription(v string)

SetDescription sets the x.Description field to v, then returns x.

func (*Message) SetTypeId added in v0.21.0

func (x *Message) SetTypeId(v *uuidpb.UUID)

SetTypeId sets the x.TypeId field to v, then returns x.

func (*Message) String added in v0.21.0

func (x *Message) String() string

func (*Message) UnmarshalBinary added in v0.21.0

func (x *Message) UnmarshalBinary(data []byte) error

UnmarshalBinary populates x from its binary representation, equivalent to calling proto.Unmarshal(data, x).

It allows *Message to implement encoding.BinaryUnmarshaler.

type MessageBuilder added in v0.21.0

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

func NewMessageBuilder added in v0.21.0

func NewMessageBuilder() *MessageBuilder

NewMessageBuilder returns a builder that constructs Message messages.

func (*MessageBuilder) Build added in v0.21.0

func (b *MessageBuilder) Build() *Message

Build returns a new Message containing the values configured via the builder.

Each call returns a new message, such that future changes to the builder do not modify previously constructed messages.

func (*MessageBuilder) From added in v0.21.0

func (b *MessageBuilder) From(x *Message) *MessageBuilder

From configures the builder to use x as the prototype for new messages, then returns b.

It performs a shallow copy of x, such that any changes made via the builder do not modify x. It does not make a copy of the field values themselves.

func (*MessageBuilder) WithData added in v0.21.0

func (b *MessageBuilder) WithData(v []byte) *MessageBuilder

WithData configures the builder to set the Data field to v, then returns b.

func (*MessageBuilder) WithDescription added in v0.21.0

func (b *MessageBuilder) WithDescription(v string) *MessageBuilder

WithDescription configures the builder to set the Description field to v, then returns b.

func (*MessageBuilder) WithTypeId added in v0.21.0

func (b *MessageBuilder) WithTypeId(v *uuidpb.UUID) *MessageBuilder

WithTypeId configures the builder to set the TypeId field to v, then returns b.

type MultiEnvelope added in v0.21.0

type MultiEnvelope struct {
	Header *Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"`
	Bodies []*Body `protobuf:"bytes,2,rep,name=bodies,proto3" json:"bodies,omitempty"`
	// contains filtered or unexported fields
}

MultiEnvelope is an efficient encoding of an ordered sequence of Envelope values that share common header context.

func (*MultiEnvelope) Descriptor deprecated added in v0.21.0

func (*MultiEnvelope) Descriptor() ([]byte, []int)

Deprecated: Use MultiEnvelope.ProtoReflect.Descriptor instead.

func (*MultiEnvelope) GetBodies added in v0.21.0

func (x *MultiEnvelope) GetBodies() []*Body

func (*MultiEnvelope) GetHeader added in v0.21.0

func (x *MultiEnvelope) GetHeader() *Header

func (*MultiEnvelope) MarshalBinary added in v0.21.0

func (x *MultiEnvelope) MarshalBinary() ([]byte, error)

MarshalBinary returns the binary representation of the message, equivalent to calling proto.Marshal(x).

It allows *MultiEnvelope to implement encoding.BinaryMarshaler.

func (*MultiEnvelope) ProtoMessage added in v0.21.0

func (*MultiEnvelope) ProtoMessage()

func (*MultiEnvelope) ProtoReflect added in v0.21.0

func (x *MultiEnvelope) ProtoReflect() protoreflect.Message

func (*MultiEnvelope) Reset added in v0.21.0

func (x *MultiEnvelope) Reset()

func (*MultiEnvelope) SetBodies added in v0.21.0

func (x *MultiEnvelope) SetBodies(v []*Body)

SetBodies sets the x.Bodies field to v, then returns x.

func (*MultiEnvelope) SetHeader added in v0.21.0

func (x *MultiEnvelope) SetHeader(v *Header)

SetHeader sets the x.Header field to v, then returns x.

func (*MultiEnvelope) String added in v0.21.0

func (x *MultiEnvelope) String() string

func (*MultiEnvelope) UnmarshalBinary added in v0.21.0

func (x *MultiEnvelope) UnmarshalBinary(data []byte) error

UnmarshalBinary populates x from its binary representation, equivalent to calling proto.Unmarshal(data, x).

It allows *MultiEnvelope to implement encoding.BinaryUnmarshaler.

func (*MultiEnvelope) Validate added in v0.21.0

func (x *MultiEnvelope) Validate() error

Validate returns an error if x is not well-formed.

Well-formedness means that all compulsory fields are populated and that no incompatible fields are populated.

It is intentionally fairly permissive, so that message meta-data can be obtained even if the message is unable to be handled.

It does not perform "deep" validation, such as ensuring messages, times, etc can be unmarshaled.

type MultiEnvelopeBuilder added in v0.21.0

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

func NewMultiEnvelopeBuilder added in v0.21.0

func NewMultiEnvelopeBuilder() *MultiEnvelopeBuilder

NewMultiEnvelopeBuilder returns a builder that constructs MultiEnvelope messages.

func (*MultiEnvelopeBuilder) Build added in v0.21.0

func (b *MultiEnvelopeBuilder) Build() *MultiEnvelope

Build returns a new MultiEnvelope containing the values configured via the builder.

Each call returns a new message, such that future changes to the builder do not modify previously constructed messages.

func (*MultiEnvelopeBuilder) From added in v0.21.0

From configures the builder to use x as the prototype for new messages, then returns b.

It performs a shallow copy of x, such that any changes made via the builder do not modify x. It does not make a copy of the field values themselves.

func (*MultiEnvelopeBuilder) WithBodies added in v0.21.0

func (b *MultiEnvelopeBuilder) WithBodies(v []*Body) *MultiEnvelopeBuilder

WithBodies configures the builder to set the Bodies field to v, then returns b.

func (*MultiEnvelopeBuilder) WithHeader added in v0.21.0

WithHeader configures the builder to set the Header field to v, then returns b.

type PackCommandOption added in v0.22.0

type PackCommandOption interface {
	// contains filtered or unexported methods
}

PackCommandOption is an option that modifies the behavior of Packer.PackCommand.

func WithIdempotencyKey added in v0.20.1

func WithIdempotencyKey(key string) PackCommandOption

WithIdempotencyKey sets the idempotency key of a command packed via Packer.PackCommand.

type PackEffectCommandOption added in v0.22.0

type PackEffectCommandOption interface {
	// contains filtered or unexported methods
}

PackEffectCommandOption is an option that modifies the behavior of EffectPacker.PackCommand.

type PackEffectEventOption added in v0.22.0

type PackEffectEventOption interface {
	// contains filtered or unexported methods
}

PackEffectEventOption is an option that modifies the behavior of EffectPacker.PackEvent.

type PackEffectTimeoutOption added in v0.22.0

type PackEffectTimeoutOption interface {
	// contains filtered or unexported methods
}

PackEffectTimeoutOption is an option that modifies the behavior of EffectPacker.PackTimeout.

func WithScheduledFor added in v0.12.1

func WithScheduledFor(t time.Time) PackEffectTimeoutOption

WithScheduledFor sets the scheduled time of a timeout packed via EffectPacker.PackTimeout.

type PackEffectsOption added in v0.22.0

type PackEffectsOption interface {
	// contains filtered or unexported methods
}

PackEffectsOption is an option that modifies the behavior of Packer.PackEffects.

func WithInstanceID added in v0.12.1

func WithInstanceID(id string) PackEffectsOption

WithInstanceID sets the aggregate or process instance ID that is the source of messages packed via Packer.PackEffects.

type Packer added in v0.12.1

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

	// GenerateID is a function used to generate new message IDs.
	//
	// If it is nil, a random 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) PackCommand added in v0.22.0

func (p *Packer) PackCommand(m dogma.Command, options ...PackCommandOption) *Envelope

PackCommand returns an envelope containing the given command.

func (*Packer) PackEffects added in v0.22.0

func (p *Packer) PackEffects(
	cause *Envelope,
	h *identitypb.Identity,
	options ...PackEffectsOption,
) *EffectPacker

PackEffects returns an EffectPacker that packs messages produced by h while handling cause.

type Source added in v0.21.0

type Source 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 `protobuf:"bytes,1,opt,name=site,proto3" json:"site,omitempty"`
	// Application is the identity of the Dogma application that produced the
	// message.
	Application *identitypb.Identity `protobuf:"bytes,2,opt,name=application,proto3" json:"application,omitempty"`
	// Handler is the identity of the Dogma handler that produced the message.
	//
	// It is the zero-value if the message was not produced by a handler.
	Handler *identitypb.Identity `protobuf:"bytes,3,opt,name=handler,proto3" json:"handler,omitempty"`
	// InstanceId is the ID of the aggregate or process instance that produced
	// the message.
	//
	// It is empty if the message was not produced by an aggregate or process
	// handler.
	InstanceId string `protobuf:"bytes,4,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"`
	// contains filtered or unexported fields
}

Source identifies where a message originated.

func (*Source) Descriptor deprecated added in v0.21.0

func (*Source) Descriptor() ([]byte, []int)

Deprecated: Use Source.ProtoReflect.Descriptor instead.

func (*Source) GetApplication added in v0.21.0

func (x *Source) GetApplication() *identitypb.Identity

func (*Source) GetHandler added in v0.21.0

func (x *Source) GetHandler() *identitypb.Identity

func (*Source) GetInstanceId added in v0.21.0

func (x *Source) GetInstanceId() string

func (*Source) GetSite added in v0.21.0

func (x *Source) GetSite() *identitypb.Identity

func (*Source) MarshalBinary added in v0.21.0

func (x *Source) MarshalBinary() ([]byte, error)

MarshalBinary returns the binary representation of the message, equivalent to calling proto.Marshal(x).

It allows *Source to implement encoding.BinaryMarshaler.

func (*Source) ProtoMessage added in v0.21.0

func (*Source) ProtoMessage()

func (*Source) ProtoReflect added in v0.21.0

func (x *Source) ProtoReflect() protoreflect.Message

func (*Source) Reset added in v0.21.0

func (x *Source) Reset()

func (*Source) SetApplication added in v0.21.0

func (x *Source) SetApplication(v *identitypb.Identity)

SetApplication sets the x.Application field to v, then returns x.

func (*Source) SetHandler added in v0.21.0

func (x *Source) SetHandler(v *identitypb.Identity)

SetHandler sets the x.Handler field to v, then returns x.

func (*Source) SetInstanceId added in v0.21.0

func (x *Source) SetInstanceId(v string)

SetInstanceId sets the x.InstanceId field to v, then returns x.

func (*Source) SetSite added in v0.21.0

func (x *Source) SetSite(v *identitypb.Identity)

SetSite sets the x.Site field to v, then returns x.

func (*Source) String added in v0.21.0

func (x *Source) String() string

func (*Source) UnmarshalBinary added in v0.21.0

func (x *Source) UnmarshalBinary(data []byte) error

UnmarshalBinary populates x from its binary representation, equivalent to calling proto.Unmarshal(data, x).

It allows *Source to implement encoding.BinaryUnmarshaler.

type SourceBuilder added in v0.21.0

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

func NewSourceBuilder added in v0.21.0

func NewSourceBuilder() *SourceBuilder

NewSourceBuilder returns a builder that constructs Source messages.

func (*SourceBuilder) Build added in v0.21.0

func (b *SourceBuilder) Build() *Source

Build returns a new Source containing the values configured via the builder.

Each call returns a new message, such that future changes to the builder do not modify previously constructed messages.

func (*SourceBuilder) From added in v0.21.0

func (b *SourceBuilder) From(x *Source) *SourceBuilder

From configures the builder to use x as the prototype for new messages, then returns b.

It performs a shallow copy of x, such that any changes made via the builder do not modify x. It does not make a copy of the field values themselves.

func (*SourceBuilder) WithApplication added in v0.21.0

func (b *SourceBuilder) WithApplication(v *identitypb.Identity) *SourceBuilder

WithApplication configures the builder to set the Application field to v, then returns b.

func (*SourceBuilder) WithHandler added in v0.21.0

func (b *SourceBuilder) WithHandler(v *identitypb.Identity) *SourceBuilder

WithHandler configures the builder to set the Handler field to v, then returns b.

func (*SourceBuilder) WithInstanceId added in v0.21.0

func (b *SourceBuilder) WithInstanceId(v string) *SourceBuilder

WithInstanceId configures the builder to set the InstanceId field to v, then returns b.

func (*SourceBuilder) WithSite added in v0.21.0

WithSite configures the builder to set the Site field to v, then returns b.

Jump to

Keyboard shortcuts

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