middleware

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2019 License: MIT Imports: 8 Imported by: 143

Documentation

Index

Constants

View Source
const CorrelationIDMetadataKey = "correlation_id"
View Source
const RetryForever = -1

Variables

View Source
var ErrInvalidPoisonQueueTopic = errors.New("invalid poison queue topic")

ErrInvalidPoisonQueueTopic occurs when the topic supplied to the PoisonQueue constructor is invalid.

View Source
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

func MessageCorrelationID

func MessageCorrelationID(message *message.Message) string

func RandomFail

func RandomFail(errorRatio float32) message.HandlerMiddleware

func RandomPanic

func RandomPanic(panicRatio float32) message.HandlerMiddleware

func SetCorrelationID

func SetCorrelationID(id string, msg *message.Message)

Types

type IgnoreErrors

type IgnoreErrors struct {
	// contains filtered or unexported fields
}

func NewIgnoreErrors

func NewIgnoreErrors(errs []error) IgnoreErrors

func (IgnoreErrors) Middleware

type OnRetryHook

type OnRetryHook func(retryNum int, delay time.Duration)

type PoisonQueue

type PoisonQueue struct {
	Middleware message.HandlerMiddleware
	// contains filtered or unexported fields
}

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 NewPoisonQueue

func NewPoisonQueue(pub message.Publisher, topic string) (PoisonQueue, error)

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

func NewThrottle(count int64, duration time.Duration) *Throttle

NewThrottle creates new Throttle instance. Example duration and count: NewThrottle(10, time.Second) for 10 messages per second

func (Throttle) Middleware

Jump to

Keyboard shortcuts

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