handler

package
v1.39.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 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 ConsumerMetricStorage

type ConsumerMetricStorage interface {
	ObserveConsumeDuration(exchange string, routingKey string, t time.Duration)
	ObserveConsumeMsgSize(exchange string, routingKey string, size int)
	IncRequeueCount(exchange string, routingKey string)
	IncDlqCount(exchange string, routingKey string)
	IncSuccessCount(exchange string, routingKey string)
	IncRetryCount(exchange string, routingKey string)
}

type Middleware

type Middleware func(next SyncHandlerAdapter) SyncHandlerAdapter

func Log

func Log(logger log.Logger) Middleware

func Metrics

func Metrics(metricStorage ConsumerMetricStorage) Middleware

type Result

type Result struct {
	Ack            bool
	Requeue        bool
	RequeueTimeout time.Duration
	Retry          bool
	MoveToDlq      bool
	Err            error
}

func Ack

func Ack() Result

func MoveToDlq

func MoveToDlq(err error) Result

MoveToDlq if there is no DLQ, the message will be dropped

func Requeue

func Requeue(after time.Duration, err error) Result

Requeue Deprecated: use Retry and RetryPolicy instead

func Retry

func Retry(err error) Result

type Sync

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

func NewSync

func NewSync(logger log.Logger, adapter SyncHandlerAdapter, middlewares ...Middleware) Sync

func (Sync) Handle

func (r Sync) Handle(ctx context.Context, delivery *consumer.Delivery)

type SyncHandlerAdapter

type SyncHandlerAdapter interface {
	Handle(ctx context.Context, delivery *consumer.Delivery) Result
}

type SyncHandlerAdapterFunc

type SyncHandlerAdapterFunc func(ctx context.Context, delivery *consumer.Delivery) Result

func (SyncHandlerAdapterFunc) Handle

func (a SyncHandlerAdapterFunc) Handle(ctx context.Context, delivery *consumer.Delivery) Result

Jump to

Keyboard shortcuts

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