Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrEmptyConfig = errors.New("empty config") ErrAddrMissing = errors.New("missing required field 'Addr'") ErrExchangeMissing = errors.New("missing required field 'Exchange'") ErrCredentialMissing = errors.New("missing RabbitMQ credentials in environment") ErrConnectionFailed = errors.New("failed to connect to RabbitMQ") ErrChannelFailed = errors.New("failed to open channel") ErrExchangeDeclare = errors.New("failed to declare exchange") )
Error variables representing different failure scenarios.
View Source
var ChannelFunc = func(conn *amqp091.Connection) (Channel, error) {
return conn.Channel()
}
ChannelFunc is a function variable used to open a channel on the given RabbitMQ connection.
View Source
var DialFunc = amqp091.Dial
DialFunc is a function variable used to establish a connection to RabbitMQ.
Functions ¶
func GetConnURL ¶
GetConnURL constructs the RabbitMQ connection URL using the config and environment credentials.
Types ¶
type Channel ¶
type Channel interface {
PublishWithContext(ctx context.Context, exchange, key string, mandatory, immediate bool, msg amqp091.Publishing) error
ExchangeDeclare(name, kind string, durable, autoDelete, internal, noWait bool, args amqp091.Table) error
Close() error
}
Channel defines the interface for publishing messages to RabbitMQ.
type Publisher ¶
type Publisher struct {
Conn *amqp091.Connection
Channel Channel
Config *Config
}
Publisher manages the RabbitMQ connection and channel to publish messages.
Click to show internal directories.
Click to hide internal directories.