Documentation
¶
Index ¶
- type Chain
- type MessageApplicableFn
- type Middleware
- func ConditionalExecute(shouldExec MessageApplicableFn, exec func(msg *message.Message) error) Middleware
- func ConditionalSkip(shouldSkipFn MessageApplicableFn) Middleware
- func ContextKeyToMetadata(metadataKey string, ctxKey any) Middleware
- func ContextTimeout(timeout time.Duration) Middleware
- func ConvertPanicToError() Middleware
- func OnError(errHandler func(msg *message.Message, err error)) Middleware
- func Throttle(max int, perDuration time.Duration) Middleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
func (*Chain) Add ¶
func (c *Chain) Add(middleware Middleware)
func (*Chain) Wrap ¶
func (c *Chain) Wrap(h message.HandlerFunc) message.HandlerFunc
type MessageApplicableFn ¶
MessageApplicableFn is a function that will return true if a message is applicable. Used by middleware to determine which messages are applicable.
type Middleware ¶
type Middleware func(h message.HandlerFunc) message.HandlerFunc
func ConditionalExecute ¶
func ConditionalExecute(shouldExec MessageApplicableFn, exec func(msg *message.Message) error) Middleware
ConditionalExecute is a middleware that will execute a function based on a condition This is useful to create middlewares like Poison queues. If the function returns true, it's sent to the exec function that would send it to a poison queue.
func ConditionalSkip ¶
func ConditionalSkip(shouldSkipFn MessageApplicableFn) Middleware
ConditionalSkip is a middleware that will skip messages based on a condition This is useful, for example, to create de-duplicator using Redis or a similar datastore. This is just a specialized version of ConditionalExecute.
func ContextKeyToMetadata ¶
func ContextKeyToMetadata(metadataKey string, ctxKey any) Middleware
Middleware to take a context key from the context and set it as message metadata Useful to take something like a correlation ID from the context and set it as metadata
func ContextTimeout ¶
func ContextTimeout(timeout time.Duration) Middleware
ContextTimeout creates a new context with the given timeout and sets it on the message
func ConvertPanicToError ¶
func ConvertPanicToError() Middleware