broker

package
v0.0.0-...-3414fa2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AMQPBroker

type AMQPBroker struct {
	// contains filtered or unexported fields
}

func NewAMQPBroker

func NewAMQPBroker(cfg *config.RabbitMQConfig) *AMQPBroker

func (*AMQPBroker) BindQueue

func (b *AMQPBroker) BindQueue(queue, exchange, routingKey string) error

func (*AMQPBroker) Channel

func (b *AMQPBroker) Channel() (*amqp.Channel, error)

func (*AMQPBroker) Close

func (b *AMQPBroker) Close() error

func (*AMQPBroker) Connect

func (b *AMQPBroker) Connect(ctx context.Context) error

func (*AMQPBroker) Consume

func (b *AMQPBroker) Consume(queue string, autoAck bool) (<-chan amqp.Delivery, error)

func (*AMQPBroker) DeclareExchange

func (b *AMQPBroker) DeclareExchange(name string, kind string) error

func (*AMQPBroker) DeclareQueue

func (b *AMQPBroker) DeclareQueue(name string) (amqp.Queue, error)

func (*AMQPBroker) Disconnect

func (b *AMQPBroker) Disconnect() error

func (*AMQPBroker) IsConnected

func (b *AMQPBroker) IsConnected() bool

func (*AMQPBroker) Publish

func (b *AMQPBroker) Publish(exchange, routingKey string, msg amqp.Publishing) error

type Broker

type Broker interface {
	// Connect connects to the message queue
	Connect(ctx context.Context) error
	// Close closes the connection
	Close() error
	// Publish publishes a message
	Publish(exchange, routingKey string, msg amqp.Publishing) error
	// Consume consumes messages from a queue
	Consume(queue string, autoAck bool) (<-chan amqp.Delivery, error)
	// DeclareExchange declares an exchange
	DeclareExchange(name string, kind string) error
	// DeclareQueue declares a queue
	DeclareQueue(name string) (amqp.Queue, error)
	// BindQueue binds a queue to an exchange
	BindQueue(queue, exchange, routingKey string) error
	// IsConnected checks the connection status
	IsConnected() bool
	// Disconnect gracefully disconnects from the broker
	Disconnect() error

	Channel() (*amqp.Channel, error)
}

Broker defines the interface for a message broker

Jump to

Keyboard shortcuts

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