Documentation ¶
Index ¶
- Constants
- Variables
- type Broker
- type Caller
- type Envelope
- type EnvelopeOption
- func FromData(data []byte) EnvelopeOption
- func WithData(encoding string, data interface{}) EnvelopeOption
- func WithHeaders(header http.Header) EnvelopeOption
- func WithID(messageID string) EnvelopeOption
- func WithNewUUID() EnvelopeOption
- func WithSource(source RouteKey) EnvelopeOption
- func WithSubject(subject RouteKey) EnvelopeOption
- func WithTime(ts time.Time) EnvelopeOption
- func WithType(messageType RouteKey) EnvelopeOption
- type Message
- type MockBroker
- type NoOpBroker
- type OnMessageErrorFunc
- type OnMessageFunc
- type Receiver
- type RetryableError
- type RouteKey
- type Sender
- type Validator
Constants ¶
const ( TextPlain = ceEvent.TextPlain ApplicationJSON = ceEvent.ApplicationJSON )
Variables ¶
var PublishTimeoutErr = errors.New("failed to publish message within timeout")
Functions ¶
This section is empty.
Types ¶
type Broker ¶
Broker an interface that describes a system that can handle inbound and outbound Message(s)
type Caller ¶
Caller is an interface that describes a system that expects to make a synchronous request to another system
type Envelope ¶
type Envelope struct { Message Error error Header http.Header // contains filtered or unexported fields }
Envelope a value object (container) for Message Allows a recipient to check if a message contained an error
func NewDefaultEnvelope ¶
func NewDefaultEnvelope(options ...EnvelopeOption) (envelope Envelope)
NewDefaultEnvelope accepts raw message bytes, attempts to unmarshall the event into a Message If there is a problem decoding the message the error will be stored on the Envelope Sets message.ID and Time
func NewEnvelope ¶
func NewEnvelope(options ...EnvelopeOption) (envelope Envelope)
NewEnvelope accepts raw message bytes, attempts to unmarshall the event into a Message If there is a problem decoding the message the error will be stored on the Envelope
func (*Envelope) SubjectKey ¶
SubjectKey returns the RouteKey of the event subject
type EnvelopeOption ¶
EnvelopeOption a higher order function that modifies properties of a message
func FromData ¶
func FromData(data []byte) EnvelopeOption
FromData accepts raw byte data an attempts to json.Unmarshal into the enveloped Message If an error occurs while unmarshalling it will be accessible from Envelope.Error
func WithData ¶
func WithData(encoding string, data interface{}) EnvelopeOption
WithData encodes the given payload with the given content type. If the provided payload is a byte array, when marshalled to json it will be encoded as base64. If the provided payload is different from byte array, datacodec.Encode is invoked to attempt a marshalling to byte array.
func WithHeaders ¶
func WithHeaders(header http.Header) EnvelopeOption
func WithID ¶
func WithID(messageID string) EnvelopeOption
WithID sets the ID property of the enveloped Message
func WithNewUUID ¶
func WithNewUUID() EnvelopeOption
WithNewUUID sets the ID property of the enveloped Message to a random UUIDv4
func WithSource ¶
func WithSource(source RouteKey) EnvelopeOption
WithSource sets the source of the enveloped Message
func WithSubject ¶
func WithSubject(subject RouteKey) EnvelopeOption
WithSubject sets the subject of the enveloped Message
func WithTime ¶
func WithTime(ts time.Time) EnvelopeOption
WithTime sets the time of the enveloped Message
func WithType ¶
func WithType(messageType RouteKey) EnvelopeOption
WithType sets the type property of the enveloped Message
type Message ¶
type Message interface { Validator json.Marshaler json.Unmarshaler event.EventReader event.EventWriter }
Message an interface
type MockBroker ¶
func NewMockBroker ¶
func NewMockBroker() *MockBroker
func (*MockBroker) Close ¶
func (m *MockBroker) Close() error
type NoOpBroker ¶
type NoOpBroker struct{}
func (NoOpBroker) Close ¶
func (m NoOpBroker) Close() error
type OnMessageErrorFunc ¶
OnMessageErrorFunc a function that processes errors that are returned from OnMessageFunc
type OnMessageFunc ¶
OnMessageFunc a function that processes an Envelope message
type Receiver ¶
type Receiver interface { Subscribe(ctx context.Context, topic RouteKey, ackDeadline *time.Duration) (<-chan Envelope, error) Close() error }
Receiver an interface that describes a system that expects to subscribe to a topic and receive Message(s)
type RetryableError ¶
type RetryableError struct {
// contains filtered or unexported fields
}
RetryableError ...
func NewRetryableError ¶
func NewRetryableError(err error) RetryableError
func (RetryableError) Cause ¶
func (r RetryableError) Cause() error
func (RetryableError) Error ¶
func (r RetryableError) Error() string
func (RetryableError) Unwrap ¶
func (r RetryableError) Unwrap() error
func (RetryableError) Wrap ¶
func (r RetryableError) Wrap(err error) error
type RouteKey ¶
type RouteKey string
RouteKey a stringer used for constructing conventional topic, source, and event names