rabbitmq

package
v0.0.0-...-31ddaea Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalProto

func MarshalProto(message proto.Message) ([]byte, error)

MarshalProto serializes a Protobuf message

func UnmarshalProto

func UnmarshalProto(data []byte, message proto.Message) error

UnmarshalProto deserializes a Protobuf message

Types

type MockRabbitMQ

type MockRabbitMQ struct {
	mock.Mock
}

func (*MockRabbitMQ) Close

func (m *MockRabbitMQ) Close()

func (*MockRabbitMQ) Consume

func (m *MockRabbitMQ) Consume(queueName string) (<-chan amqp091.Delivery, error)

func (*MockRabbitMQ) DeclareExchange

func (m *MockRabbitMQ) DeclareExchange(exchangeName, exchangeType string) error

func (*MockRabbitMQ) Publish

func (m *MockRabbitMQ) Publish(exchange, routingKey string, body []byte) error

func (*MockRabbitMQ) SetupQueue

func (m *MockRabbitMQ) SetupQueue(queueName, exchangeName string, routingKeys []string) error

type RabbitMQ

type RabbitMQ struct {
	Conn    *amqp091.Connection
	Channel *amqp091.Channel
}

func NewRabbitMQ

func NewRabbitMQ(url string) (*RabbitMQ, error)

NewRabbitMQ initializes a RabbitMQ connection and channel

func (*RabbitMQ) Close

func (x *RabbitMQ) Close()

Close closes the RabbitMQ connection and channel

func (*RabbitMQ) Consume

func (x *RabbitMQ) Consume(queueName string) (<-chan amqp091.Delivery, error)

Consume starts consuming messages from the specified queue

func (*RabbitMQ) DeclareExchange

func (x *RabbitMQ) DeclareExchange(exchangeName, exchangeType string) error

DeclareExchange declares an exchange if it doesn't exist

func (*RabbitMQ) Publish

func (x *RabbitMQ) Publish(exchange, routingKey string, body []byte) error

Publish sends a message to the specified exchange and routing key

func (*RabbitMQ) SetupQueue

func (x *RabbitMQ) SetupQueue(queueName, exchangeName string, routingKeys []string) error

SetupQueue declares a queue and binds it to multiple routing keys

type RabbitMQInterface

type RabbitMQInterface interface {
	Close()
	DeclareExchange(exchangeName, exchangeType string) error
	Publish(exchange, routingKey string, body []byte) error
	SetupQueue(queueName, exchangeName string, routingKeys []string) error
	Consume(queueName string) (<-chan amqp091.Delivery, error)
}

Jump to

Keyboard shortcuts

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