Documentation
¶
Index ¶
- func CalculateRetryDelay(retryCount int, config RetryConfig) time.Duration
- func GetRetryCount(msg amqp.Delivery) int
- func ScheduleRetry(channel *amqp.Channel, config *Config, body []byte, headers amqp.Table, ...)
- type Config
- func (qc *Config) GetQueueArguments() amqp.Table
- func (qc *Config) SetupAllQueues(ch *amqp.Channel) error
- func (qc *Config) SetupDeadLetterExchange(ch *amqp.Channel) error
- func (qc *Config) SetupDeadLetterQueue(ch *amqp.Channel) error
- func (qc *Config) SetupExchange(ch *amqp.Channel) error
- func (qc *Config) SetupMainQueue(ch *amqp.Channel) error
- type ConnectionConfig
- type Consumer
- type MessageHandler
- type Producer
- type RetryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateRetryDelay ¶
func CalculateRetryDelay(retryCount int, config RetryConfig) time.Duration
CalculateRetryDelay calculates delay with exponential backoff
func GetRetryCount ¶
GetRetryCount extracts the retry count from message headers
Types ¶
type Config ¶
type Config struct {
ExchangeName string
ExchangeType string // "direct", "topic", "fanout", "headers" - defaults to "direct"
QueueName string
RoutingKey string
DLXExchangeName string
DLQName string
DLQRoutingKey string
}
Config holds the configuration for RabbitMQ queues and exchanges
func (*Config) GetQueueArguments ¶
GetQueueArguments returns the queue arguments for both main queue and DLQ
func (*Config) SetupAllQueues ¶
SetupAllQueues sets up all exchanges and queues
func (*Config) SetupDeadLetterExchange ¶
SetupDeadLetterExchange declares the dead letter exchange
func (*Config) SetupDeadLetterQueue ¶
SetupDeadLetterQueue declares the dead letter queue
func (*Config) SetupExchange ¶
SetupExchange declares the main exchange
type ConnectionConfig ¶
type ConnectionConfig struct {
Host string
Port string
Username string
Password string
VHost string
}
ConnectionConfig holds RabbitMQ connection details
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
Consumer is a RabbitMQ consumer with automatic reconnection
func NewConsumer ¶
func NewConsumer(connConfig ConnectionConfig, queueConfig *Config, retryConfig RetryConfig, handler MessageHandler) (*Consumer, error)
NewConsumer creates a new RabbitMQ consumer with automatic reconnection
func (*Consumer) IsConnected ¶
IsConnected returns true if the consumer has a valid connection
func (*Consumer) StartConsuming ¶
StartConsuming starts consuming messages from the queue
type MessageHandler ¶
MessageHandler is a function that processes a message It should return an error if processing failed and retry is needed
type Producer ¶ added in v1.7.0
type Producer struct {
// contains filtered or unexported fields
}
Producer is a RabbitMQ producer with automatic reconnection
func NewProducer ¶ added in v1.7.0
func NewProducer(connConfig ConnectionConfig, queueConfig *Config) (*Producer, error)
NewProducer creates a new RabbitMQ producer with automatic reconnection
func (*Producer) IsConnected ¶ added in v1.7.0
IsConnected returns true if the producer has a valid connection
type RetryConfig ¶
RetryConfig holds retry configuration