Documentation
¶
Overview ¶
Package topology provides types and functions for defining RabbitMQ topology including exchanges, queues, and bindings.
Index ¶
- Constants
- type Binding
- type Declarations
- type DeclarationsOption
- func WithBinding(exchangeName string, queueName string, routingKey string) DeclarationsOption
- func WithDirectExchange(name string) DeclarationsOption
- func WithFanoutExchange(name string) DeclarationsOption
- func WithQueue(name string, opts ...QueueOption) DeclarationsOption
- func WithTopicExchange(name string) DeclarationsOption
- type Exchange
- type Queue
- type QueueOption
Constants ¶
const ( // DLXName is the name of the default dead-letter exchange. DLXName = "default-dead-letter" // DLQSuffix is the suffix for dead-letter queues. DLQSuffix = "DLQ" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Declarations ¶
Declarations represents a complete topology configuration.
func Compile ¶
func Compile(cfg Declarations) Declarations
Compile processes the declarations and automatically creates dead-letter queues, retry queues, and their associated bindings based on the configuration.
func New ¶
func New(opts ...DeclarationsOption) Declarations
New creates a new Declarations instance with the specified options.
type DeclarationsOption ¶
type DeclarationsOption func(d *Declarations)
DeclarationsOption is a function that configures a Declarations instance.
func WithBinding ¶
func WithBinding(exchangeName string, queueName string, routingKey string) DeclarationsOption
WithBinding adds a binding between an exchange and a queue.
func WithDirectExchange ¶
func WithDirectExchange(name string) DeclarationsOption
WithDirectExchange adds a direct exchange to the declarations.
func WithFanoutExchange ¶
func WithFanoutExchange(name string) DeclarationsOption
WithFanoutExchange adds a fanout exchange to the declarations.
func WithQueue ¶
func WithQueue(name string, opts ...QueueOption) DeclarationsOption
WithQueue adds a queue to the declarations.
func WithTopicExchange ¶
func WithTopicExchange(name string) DeclarationsOption
WithTopicExchange adds a topic exchange to the declarations.
type Exchange ¶
Exchange represents a RabbitMQ exchange configuration.
func NewDirectExchange ¶
NewDirectExchange creates a new direct exchange.
func NewFanoutExchange ¶
NewFanoutExchange creates a new fanout exchange.
func NewTopicExchange ¶
NewTopicExchange creates a new topic exchange.
type Queue ¶
type Queue struct {
Name string
DLQ bool
Durable bool
AutoDelete bool
RetryPolicy *retry.Policy
Args amqp.Table
}
Queue represents a RabbitMQ queue configuration.
func NewQueue ¶
func NewQueue(name string, opts ...QueueOption) *Queue
NewQueue creates a new queue with the specified name and optional configuration. By default, queues are created as durable.
type QueueOption ¶
type QueueOption func(q *Queue)
QueueOption is a function that configures a Queue instance.
func WithAutoDelete ¶
func WithAutoDelete(value bool) QueueOption
WithAutoDelete configures whether the queue is deleted when no longer in use.
func WithDLQ ¶
func WithDLQ(value bool) QueueOption
WithDLQ configures whether the queue is a dead-letter queue.
func WithDurable ¶
func WithDurable(value bool) QueueOption
WithDurable configures whether the queue survives broker restarts.
func WithQueueArg ¶
func WithQueueArg(key string, value any) QueueOption
WithQueueArg sets a custom argument for the queue.
func WithRetryPolicy ¶
func WithRetryPolicy(policy retry.Policy) QueueOption
WithRetryPolicy configures the retry policy for the queue.