Documentation ¶
Index ¶
- Constants
- Variables
- func CorrelationID(h message.HandlerFunc) message.HandlerFunc
- func InstantAck(h message.HandlerFunc) message.HandlerFunc
- func MessageCorrelationID(message *message.Message) string
- func PoisonQueue(pub message.Publisher, topic string) (message.HandlerMiddleware, error)
- func PoisonQueueWithFilter(pub message.Publisher, topic string, ...) (message.HandlerMiddleware, error)
- func RandomFail(errorRatio float32) message.HandlerMiddleware
- func RandomPanic(panicRatio float32) message.HandlerMiddleware
- func Recoverer(h message.HandlerFunc) message.HandlerFunc
- func SetCorrelationID(id string, msg *message.Message)
- type IgnoreErrors
- type OnRetryHook
- type RecoveredPanicError
- type Retry
- type Throttle
Constants ¶
const CorrelationIDMetadataKey = "correlation_id"
const RetryForever = -1
Variables ¶
var ErrInvalidPoisonQueueTopic = errors.New("invalid poison queue topic")
ErrInvalidPoisonQueueTopic occurs when the topic supplied to the PoisonQueue constructor is invalid.
var ReasonForPoisonedKey = "reason_poisoned"
ReasonForPoisonedKey is the metadata key which marks the reason (error) why the message was deemed poisoned.
Functions ¶
func CorrelationID ¶
func CorrelationID(h message.HandlerFunc) message.HandlerFunc
CorrelationID adds correlation ID to all messages produced by the handler. ID is based on ID from message received by handler.
To make CorrelationID working correctly, SetCorrelationID must be called to first message entering the system.
func InstantAck ¶
func InstantAck(h message.HandlerFunc) message.HandlerFunc
func MessageCorrelationID ¶
MessageCorrelationID returns correlation ID from the message.
func PoisonQueue ¶
PoisonQueue provides a middleware that salvages unprocessable messages and published them on a separate topic. The main middleware chain then continues on, business as usual.
func PoisonQueueWithFilter ¶ added in v0.4.0
func RandomFail ¶
func RandomFail(errorRatio float32) message.HandlerMiddleware
func RandomPanic ¶
func RandomPanic(panicRatio float32) message.HandlerMiddleware
func Recoverer ¶
func Recoverer(h message.HandlerFunc) message.HandlerFunc
func SetCorrelationID ¶
SetCorrelationID sets a correlation ID for the message.
SetCorrelationID should be called when the message enters the system. When message is produced in a request (for example HTTP), message correlation ID should be the same as the request's correlation ID.
Types ¶
type IgnoreErrors ¶
type IgnoreErrors struct {
// contains filtered or unexported fields
}
func NewIgnoreErrors ¶
func NewIgnoreErrors(errs []error) IgnoreErrors
func (IgnoreErrors) Middleware ¶
func (i IgnoreErrors) Middleware(h message.HandlerFunc) message.HandlerFunc
type OnRetryHook ¶
type RecoveredPanicError ¶ added in v0.3.0
type RecoveredPanicError struct { V interface{} Stacktrace string }
func (RecoveredPanicError) Error ¶ added in v0.3.0
func (p RecoveredPanicError) Error() string
type Retry ¶
type Retry struct { MaxRetries int WaitTime time.Duration Backoff int64 MaxDelay time.Duration OnRetryHook OnRetryHook Logger watermill.LoggerAdapter }
func (Retry) Middleware ¶
func (r Retry) Middleware(h message.HandlerFunc) message.HandlerFunc
type Throttle ¶
type Throttle struct {
// contains filtered or unexported fields
}
func NewThrottle ¶ added in v0.1.2
NewThrottle creates new Throttle instance. Example duration and count: NewThrottle(10, time.Second) for 10 messages per second
func (Throttle) Middleware ¶
func (t Throttle) Middleware(h message.HandlerFunc) message.HandlerFunc