messagequeue

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExchangeOptions

type ExchangeOptions struct {
	Durable    bool
	AutoDelete bool
	Internal   bool
	NoWait     bool
	Arguments  amqp091.Table
}

ExchangeOptions represents options for declaring exchanges

func DefaultExchangeOptions

func DefaultExchangeOptions() ExchangeOptions

DefaultExchangeOptions returns default exchange options

type MessageHandler

type MessageHandler func(ctx context.Context, msg amqp091.Delivery) error

MessageHandler is a function that handles consumed messages

type PublishOptions

type PublishOptions struct {
	ContentType  string
	DeliveryMode uint8
	Priority     uint8
	Expiration   string
	MessageID    string
	UserID       string
	AppID        string
	Headers      amqp091.Table
	Mandatory    bool
	Immediate    bool
}

PublishOptions represents options for publishing messages

func DefaultPublishOptions

func DefaultPublishOptions() PublishOptions

DefaultPublishOptions returns default publishing options

type QueueOptions

type QueueOptions struct {
	Durable    bool
	AutoDelete bool
	Exclusive  bool
	NoWait     bool
	Arguments  amqp091.Table
}

QueueOptions represents options for declaring queues

func DefaultQueueOptions

func DefaultQueueOptions() QueueOptions

DefaultQueueOptions returns default queue options

type RabbitMQ

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

RabbitMQ represents a RabbitMQ client

func NewRabbitMQ

func NewRabbitMQ(cfg config.RabbitMQConfig, logger *slog.Logger) (*RabbitMQ, error)

NewRabbitMQ creates a new RabbitMQ client

func (*RabbitMQ) BindQueue

func (rq *RabbitMQ) BindQueue(queue, exchange, routingKey string, args amqp091.Table) error

BindQueue binds a queue to an exchange

func (*RabbitMQ) Close

func (rq *RabbitMQ) Close() error

Close closes the RabbitMQ connection

func (*RabbitMQ) Consume

func (rq *RabbitMQ) Consume(ctx context.Context, queue string, handler MessageHandler) error

Consume consumes messages from a queue

func (*RabbitMQ) DeclareExchange

func (rq *RabbitMQ) DeclareExchange(name, exchangeType string, options ExchangeOptions) error

DeclareExchange declares an exchange

func (*RabbitMQ) DeclareQueue

func (rq *RabbitMQ) DeclareQueue(name string, options QueueOptions) (amqp091.Queue, error)

DeclareQueue declares a queue

func (*RabbitMQ) GetChannel

func (rq *RabbitMQ) GetChannel(name string) (*amqp091.Channel, error)

GetChannel returns a channel for the given name

func (*RabbitMQ) IsConnected

func (rq *RabbitMQ) IsConnected() bool

IsConnected returns the connection status

func (*RabbitMQ) Publish

func (rq *RabbitMQ) Publish(ctx context.Context, exchange, routingKey string, body []byte) error

Publish publishes a message to an exchange

func (*RabbitMQ) PublishWithOptions

func (rq *RabbitMQ) PublishWithOptions(ctx context.Context, exchange, routingKey string, body []byte, options PublishOptions) error

PublishWithOptions publishes a message with custom options

Jump to

Keyboard shortcuts

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