middleware

package
v0.0.0-...-f414a8c Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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 NewChain

func NewChain() *Chain

func (*Chain) Add

func (c *Chain) Add(middleware Middleware)

func (*Chain) Wrap

type MessageApplicableFn

type MessageApplicableFn = func(msg *message.Message) bool

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

func OnError

func OnError(errHandler func(msg *message.Message, err error)) Middleware

func Throttle

func Throttle(max int, perDuration time.Duration) Middleware

Throttle applies a global throttle to the handler. This will throttle the whole publisher or subscriber to that number of messages

Jump to

Keyboard shortcuts

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