rabbit

package
v0.0.0-...-489484a Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotConnected             = errors.New("not connected to a server")
	ErrAlreadyClosed            = errors.New("already closed: not connected to the server")
	ErrShutdown                 = errors.New("client is shutting down")
	ErrConnectionFailed         = errors.New("failed to connect to rabbitmq server")
	ErrCannotConfirmChannel     = errors.New("cannot set confirm mode")
	ErrCannotDeclareExchange    = errors.New("cannot declare exchange")
	ErrCannotDeclareQueue       = errors.New("cannot declare queue")
	ErrCannotBindQueue          = errors.New("cannot bind queue")
	ErrPublisherOptionsNotSet   = errors.New("publisher options not set")
	ErrConsumerOptionsNotSet    = errors.New("consumer options not set")
	ErrChannelNotInitialized    = errors.New("channel not initialized")
	ErrChannelCloseFailed       = errors.New("failed to close channel")
	ErrConnectionCloseFailed    = errors.New("failed to close connection")
	ErrFailedToSetPrefetchCount = errors.New("failed to set prefetch count")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Delivery <-chan amqp.Delivery
	Ready    chan bool
	// contains filtered or unexported fields
}

func New

func New(
	connectionOptions options.ConnectionOptions,
	exchangeOptions options.ExchangeOptions,
	queueOptions options.QueueOptions,
	topic string,
	publisherOptions *options.PublisherOptions,
	consumerOptions *options.ConsumerOptions,
	readyChan chan bool,
) *Client

New creates a new consumer state instance, and automatically attempts to connect to the server.

func (*Client) Close

func (client *Client) Close() error

Close will cleanly shut down the channel and connection.

func (*Client) Consume

func (client *Client) Consume() (<-chan amqp.Delivery, error)

Consume will continuously put queue items on the channel. It is required to call delivery.Ack when it has been successfully processed, or delivery.Nack when it fails. Ignoring this will cause data to build up on the server.

func (*Client) Push

func (client *Client) Push(message amqp.Publishing) error

Push will push data onto the queue, and wait for a confirm. This will block until the server sends a confirm. Errors are only returned if the push action itself fails, see UnsafePush.

func (*Client) SetNotifyClose

func (client *Client) SetNotifyClose(notifyClose chan *amqp.Error)

SetNotifyClose will set the notify close channel

func (*Client) UnsafePush

func (client *Client) UnsafePush(message amqp.Publishing) error

UnsafePush will push to the queue without checking for confirmation. It returns an error if it fails to connect. No guarantees are provided for whether the server will receive the message.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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