gorabbit

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 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 Client

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

Client is a RabbitMQ client.

func New

func New(addr string, ops ...Option) *Client

New creates a new RabbitMQ client.

func (*Client) Channel

func (c *Client) Channel() *amqp.Channel

Channel returns the current channel. Please note that the channel can be closed and Client will re-open another one and use it, but this one will remain closed.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection and channel.

func (*Client) Consume

func (c *Client) Consume(ctx context.Context, queue string, prefetch int, deliveries chan<- amqp.Delivery) error

Consume consumes messages from a queue into deliveries channel.

func (*Client) IsLive

func (c *Client) IsLive() bool

IsLive returns true if connection and channel are opened.

func (*Client) IsReady

func (c *Client) IsReady() bool

IsReady returns true if connection and channel are opened and ready to use.

func (*Client) Iter

func (c *Client) Iter(ctx context.Context, queue string, prefetch int) func(yield func(delivery amqp.Delivery) bool) error

Iter iterates over messages from a queue.

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, exchange, key string, pub amqp.Publishing) error

Publish publishes a message to an exchange.

type Option

type Option func(c *Client)

Option is a configuration option for the client.

func WithBackoff

func WithBackoff(bo backoff.BackOff) Option

WithBackoff sets the backoff strategy for reconnecting.

func WithDialConfig

func WithDialConfig(fns ...func(c *amqp.Config)) Option

WithDialConfig allows to configure the dial config.

func WithOnChannelClosed

func WithOnChannelClosed(fn func(error)) Option

WithOnChannelClosed sets the function to be called when the channel is closed.

func WithOnConnectionClosed

func WithOnConnectionClosed(fn func(error)) Option

WithOnConnectionClosed sets the function to be called when the connection is closed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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