rabbitmq

package
v0.0.0-...-f9b5f64 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MqUrl = fmt.Sprintf("amqp://%s:%s@%s:%d/%v",
		config.Viper.GetString("server.username"),
		config.Viper.GetString("server.password"),
		config.Viper.GetString("server.host"),
		config.Viper.GetInt("server.port"),
		config.Viper.GetString("server.vhost"),
	)
)

Functions

func EmitLogs

func EmitLogs()

EmitLogs 发布/订阅:生产者

func ReceiveLogs

func ReceiveLogs()

ReceiveLogs 发布/订阅:消费者

Types

type RabbitMQ

type RabbitMQ struct {

	//队列名称
	QueueName string
	//交换机名称
	Exchange string
	//bind Key 名称
	Key string
	//连接信息
	Mqurl string
	Queue amqp.Queue
	// contains filtered or unexported fields
}

rabbitMQ结构体

func NewRabbitMQ

func NewRabbitMQ(queueName string, exchange string, key string, prefetchCount int) *RabbitMQ

创建结构体实例

func NewRabbitMQSimple

func NewRabbitMQSimple(queueName string, autoAck bool) *RabbitMQ

创建简单模式下RabbitMQ实例

func (*RabbitMQ) ConsumeSimple

func (r *RabbitMQ) ConsumeSimple() (<-chan amqp.Delivery, error)

ConsumeSimple simple 模式下消费者

func (*RabbitMQ) DeclareQueue

func (r *RabbitMQ) DeclareQueue() error

func (*RabbitMQ) Destroy

func (r *RabbitMQ) Destroy()

断开channel 和 connection

func (*RabbitMQ) PublishSimple

func (r *RabbitMQ) PublishSimple(ctx context.Context, message []byte) error

PublishSimple 简单模式队列生产

Jump to

Keyboard shortcuts

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