middleware

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AckDelivery

func AckDelivery(onErrFn OnErrFunc) amqprpc.ServerMiddlewareFunc

AckDelivery is a middleware that will acknowledge the delivery after the handler has been executed. If the Ack fails the error and the `amqp.Delivery` will be passed to the `OnErrFunc`.

func PanicRecovery

func PanicRecovery(onRecovery func(interface{}, context.Context, *amqprpc.ResponseWriter, amqp.Delivery)) amqprpc.ServerMiddlewareFunc

PanicRecovery is a middleware that will recover any panics caused by a handler down the middleware chain. If a panic happens the onRecovery func will be called with the return value from recover().

func PanicRecoveryLogging

func PanicRecoveryLogging(logFunc amqprpc.LogFunc) amqprpc.ServerMiddlewareFunc

PanicRecoveryLogging is a middleware that will recover any panics caused by a handler down the middleware chain. If a panic happens the value will be logged to the provided logFunc.

Types

type OnErrFunc

type OnErrFunc func(err error, delivery amqp.Delivery)

OnErrFunc is the function that will be called when the middleware get an error from `Ack`. The error and the delivery will be passed.

func OnAckErrorLog

func OnAckErrorLog(logFn amqprpc.LogFunc) OnErrFunc

OnAckErrorLog is a built-in function that will log the error if any is returned from `Ack`.

middleware := AckDelivery(OnAckErrorLog(log.Printf))

func OnAckErrorSendOnChannel

func OnAckErrorSendOnChannel(logFn amqprpc.LogFunc, ch chan struct{}) OnErrFunc

OnAckErrorSendOnChannel will first log the error and correlation ID and then try to send on the passed channel. If no one is consuming on the passed channel the middleware will not block but instead log a message about missing channel consumers.

Jump to

Keyboard shortcuts

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