Documentation
¶
Overview ¶
Package rabbitmq provides RabbitMQ connection and messaging functionality. It includes connection management, health checks, and message publishing/consuming.
Index ¶
- type RabbitMQConnection
- func (rc *RabbitMQConnection) Close() error
- func (rc *RabbitMQConnection) Connect() error
- func (rc *RabbitMQConnection) ConnectWithRetry(ctx context.Context) error
- func (rc *RabbitMQConnection) EnablePublisherConfirms(enabled bool)
- func (rc *RabbitMQConnection) GetNewConnect() (*amqp.Channel, error)
- func (rc *RabbitMQConnection) HealthCheck() bool
- func (rc *RabbitMQConnection) IsHealthy() bool
- func (rc *RabbitMQConnection) PublishWithConfirm(ctx context.Context, exchange, routingKey string, mandatory, immediate bool, ...) error
- func (rc *RabbitMQConnection) SetReconnectionConfig(interval time.Duration, maxAttempts int)
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