rabbitmq

package
v1.13.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package rabbitmq provides RabbitMQ connection and messaging functionality. It includes connection management, health checks, and message publishing/consuming.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RabbitMQConnection

type RabbitMQConnection struct {
	ConnectionStringSource string
	Queue                  string
	Host                   string
	Port                   string
	User                   string
	Pass                   string
	Channel                *amqp.Channel
	Connection             *amqp.Connection
	Logger                 log.Logger
	Connected              bool
	// contains filtered or unexported fields
}

RabbitMQConnection is a hub which deal with rabbitmq connections. The type name intentionally matches the package name for clarity in external usage.

func (*RabbitMQConnection) Close added in v1.12.1

func (rc *RabbitMQConnection) Close() error

Close properly closes the RabbitMQ connection and channel

func (*RabbitMQConnection) Connect

func (rc *RabbitMQConnection) Connect() error

Connect keeps a singleton connection with rabbitmq.

func (*RabbitMQConnection) ConnectWithRetry added in v1.12.1

func (rc *RabbitMQConnection) ConnectWithRetry(ctx context.Context) error

ConnectWithRetry attempts to connect with automatic retry logic

func (*RabbitMQConnection) EnablePublisherConfirms added in v1.12.1

func (rc *RabbitMQConnection) EnablePublisherConfirms(enabled bool)

EnablePublisherConfirms enables publisher confirms for reliable message delivery

func (*RabbitMQConnection) GetNewConnect

func (rc *RabbitMQConnection) GetNewConnect() (*amqp.Channel, error)

GetNewConnect returns a pointer to the rabbitmq connection, initializing it if necessary.

func (*RabbitMQConnection) HealthCheck added in v1.8.0

func (rc *RabbitMQConnection) HealthCheck() bool

HealthCheck rabbitmq when the server is started

func (*RabbitMQConnection) IsHealthy added in v1.12.1

func (rc *RabbitMQConnection) IsHealthy() bool

IsHealthy checks if the connection is healthy

func (*RabbitMQConnection) PublishWithConfirm added in v1.12.1

func (rc *RabbitMQConnection) PublishWithConfirm(ctx context.Context, exchange, routingKey string, mandatory, immediate bool, msg amqp.Publishing) error

PublishWithConfirm publishes a message and waits for confirmation

func (*RabbitMQConnection) SetReconnectionConfig added in v1.12.1

func (rc *RabbitMQConnection) SetReconnectionConfig(interval time.Duration, maxAttempts int)

SetReconnectionConfig configures connection recovery settings

Jump to

Keyboard shortcuts

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