consume

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

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

Batch consumes messages in batches. Implements rabbitmq.Consumer.

func InBatches

func InBatches(amount int, timeout time.Duration, tx BatchTransaction, rejectRequeue bool, mws ...BatchMiddleware) *Batch

InBatches creates new batch consumer. One batch is `amount` of messages or until timeout, whichever comes first.

func (*Batch) Process

func (c *Batch) Process(ctx context.Context, deliveries <-chan amqp.Delivery) error

Process messages in batches.

type BatchDeliveryHandler

type BatchDeliveryHandler func(context.Context, []amqp.Delivery) (status []error)

BatchDeliveryHandler specifies how to handle batch of RabbitMQ deliveries. Returns one-to-one errors of processed deliveries.

type BatchMiddleware

type BatchMiddleware func(BatchDeliveryHandler) BatchDeliveryHandler

BatchMiddleware specifies middlewares for processing batch of RabbitMQ deliveries. Could be used for logging, tracing, etc.

type BatchTransaction

type BatchTransaction func(context.Context, [][]byte) (status []error)

BatchTransaction defines process function for handling batch of messages. Batch is a slice of messages, should return slice of one-to-one errors for each message.

type DeliveryHandler

type DeliveryHandler func(context.Context, amqp.Delivery) error

DeliveryHandler specifies how to handle raw RabbitMQ delivery.

type Middleware

type Middleware func(DeliveryHandler) DeliveryHandler

Middleware specifies middlewares for processing RabbitMQ delivery. Could be used for logging, tracing, etc.

type One

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

One consumes messages one-by-one.

func ByOne

func ByOne(tx Transaction, rejectRequeue bool, mws ...Middleware) *One

ByOne creates new One consumer. It passes message into transaction and automatically ack/reject based on transaction's returned error.

func (*One) Process

func (c *One) Process(ctx context.Context, deliveries <-chan amqp.Delivery) error

Process deliveries.

type Transaction

type Transaction func(context.Context, []byte) error

Transaction defines process function for handling single message.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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