rabbitmq

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: MIT Imports: 5 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

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"` // 路由
}

type ConsumeHandler

type ConsumeHandler func(d amqp.Delivery) error

type RabbitMQ

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

func New

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

创建RabbitMQ

func (*RabbitMQ) Channel

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

获取通道

func (*RabbitMQ) Close

func (r *RabbitMQ) Close() error

关闭连接

func (*RabbitMQ) Consume

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

func (*RabbitMQ) Produce

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

生产消息

Jump to

Keyboard shortcuts

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