rabbitx

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Apply

type Apply func(ch *amqp.Channel) error

Apply 应用方法

type Config

type Config struct {
	Address    string `mapstructure:"address"`     // rabbitmq连接地址
	VHost      string `mapstructure:"vhost"`       // 虚拟路径
	Heartbeat  int    `mapstructure:"heartbeat"`   // 心跳间隔时间
	Exchange   string `mapstructure:"exchange"`    // 交换机名称
	Queue      string `mapstructure:"queue"`       // 队列名称
	RoutingKey string `mapstructure:"routing_key"` // 路由
}

Config 消息队列配置信息

type ConsumeHandler

type ConsumeHandler func(d amqp.Delivery) error

ConsumeHandler 消费者监听

type RabbitMQ

type RabbitMQ struct {
	Address string      // 连接地址
	Config  amqp.Config // 连接配置
	// contains filtered or unexported fields
}

RabbitMQ 消息队列实例

func New

func New(addr string, cfg amqp.Config, f Apply) *RabbitMQ

New 创建RabbitMQ

func (*RabbitMQ) Channel

func (r *RabbitMQ) Channel(timeout time.Duration) (*amqp.Channel, error)

Channel 获取通道

func (*RabbitMQ) Close

func (r *RabbitMQ) Close() error

Close 关闭连接

func (*RabbitMQ) Consume

func (r *RabbitMQ) Consume(queue, consumer string, autoAck, exclusive, noLocal, noWait bool, args amqp.Table, handler ConsumeHandler)

Consume 消费方法

func (*RabbitMQ) Produce

func (r *RabbitMQ) Produce(exchange, key string, mandatory, immediate bool, data []byte) error

Produce 生产消息

Jump to

Keyboard shortcuts

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