Documentation ¶
Index ¶
- Constants
- func New(payload []byte, channel string) *watermillmessage.Message
- func UnmarshalMetadata(msg *watermillmessage.Message, key string, unmarshalTo interface{}) error
- func ValidationErrorToMessage(msg *watermillmessage.Message, validationErr *ValidationError) error
- type ValidationError
- type Validator
- type WatermillLogrusLogger
- func (l WatermillLogrusLogger) Debug(msg string, fields watermill.LogFields)
- func (l WatermillLogrusLogger) Error(msg string, err error, fields watermill.LogFields)
- func (l WatermillLogrusLogger) Info(msg string, fields watermill.LogFields)
- func (l WatermillLogrusLogger) Trace(msg string, fields watermill.LogFields)
- func (l WatermillLogrusLogger) With(fields watermill.LogFields) watermill.LoggerAdapter
Constants ¶
const ( // MetadataChannel is the key used for storing the Channel in the message Metadata. MetadataChannel = "_asyncapi_eg_channel" // MetadataValidationError is the key used for storing the Validation Error if applies. MetadataValidationError = "_asyncapi_eg_validation_error" )
The following constants are the keys on a watermill.Message Metadata where we store valuable and needed domain metadata. All contain the prefix `_asyncapi_eg_` so they can be unique-ish and human-readable. As a note: The term `eg` is a short version of Event-Gateway.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(payload []byte, channel string) *watermillmessage.Message
New creates a new watermillmessage.Message. It injects the Channel as Metadata.
func UnmarshalMetadata ¶
func UnmarshalMetadata(msg *watermillmessage.Message, key string, unmarshalTo interface{}) error
UnmarshalMetadata extracts a value from the Message Metadata and unmarshals it to the given object.
func ValidationErrorToMessage ¶
func ValidationErrorToMessage(msg *watermillmessage.Message, validationErr *ValidationError) error
ValidationErrorToMessage sets a ValidationError to the given message Metadata.
Types ¶
type ValidationError ¶
ValidationError represents a message validation error.
func NewValidationError ¶
func NewValidationError(ts time.Time, errors ...string) *ValidationError
NewValidationError creates a new ValidationError.
func ValidationErrorFromMessage ¶
func ValidationErrorFromMessage(msg *watermillmessage.Message) (*ValidationError, error)
ValidationErrorFromMessage extracts a ValidationError from the message Metadata if exists.
func (ValidationError) Error ¶
func (v ValidationError) Error() string
type Validator ¶
type Validator func(*watermillmessage.Message) (*ValidationError, error)
Validator validates a message. In case the message is invalid, returns a ValidationError. The second returned value is an error during validating process.
func JSONSchemaMessageValidator ¶
func JSONSchemaMessageValidator(messageSchemas map[string]gojsonschema.JSONLoader, idProvider func(msg *watermillmessage.Message) string) (Validator, error)
JSONSchemaMessageValidator validates a message payload based on a map of Json Schema, where the key can be any identifier (depends on who implements it). For example, the identifier can be its channel name, message ID, etc.
type WatermillLogrusLogger ¶
WatermillLogrusLogger is a wrapper of a Logrus logger implementing watermill.LoggerAdapter interface.
func NewWatermillLogrusLogger ¶
func NewWatermillLogrusLogger(logger *logrus.Logger) *WatermillLogrusLogger
NewWatermillLogrusLogger creates a new WatermillLogrusLogger.
func (WatermillLogrusLogger) Debug ¶
func (l WatermillLogrusLogger) Debug(msg string, fields watermill.LogFields)
func (WatermillLogrusLogger) Error ¶
func (l WatermillLogrusLogger) Error(msg string, err error, fields watermill.LogFields)
func (WatermillLogrusLogger) Info ¶
func (l WatermillLogrusLogger) Info(msg string, fields watermill.LogFields)
func (WatermillLogrusLogger) Trace ¶
func (l WatermillLogrusLogger) Trace(msg string, fields watermill.LogFields)
func (WatermillLogrusLogger) With ¶
func (l WatermillLogrusLogger) With(fields watermill.LogFields) watermill.LoggerAdapter