Documentation ¶
Index ¶
- Constants
- Variables
- func Init(rbInfo *RbInfo)
- type ConsumeOpt
- type DialOption
- func WithConsumeOpt(consumeOpt ConsumeOpt) DialOption
- func WithDeadDurable(durable bool) DialOption
- func WithDeadExchangeOpt(exchangeOpt ExchangeDeclareOpt) DialOption
- func WithDeadQueueBindOpt(queueBindOpt QueueBindOpt) DialOption
- func WithDeadQueueOpt(queueOpt QueueDeclareOpt) DialOption
- func WithDurable(durable bool) DialOption
- func WithExchangeOpt(exchangeOpt ExchangeDeclareOpt) DialOption
- func WithQueueBindOpt(queueBindOpt QueueBindOpt) DialOption
- func WithQueueOpt(queueOpt QueueDeclareOpt) DialOption
- func WithReconnectDelay(reconnectDelay time.Duration) DialOption
- func WithResendDelay(resendDelay time.Duration) DialOption
- type ExchangeDeclareOpt
- type QueueBindOpt
- type QueueDeclareOpt
- type RbInfo
- type RbMqClient
- func NewAndInitRabbitClient(rbInfo RbInfo, callBack func(amqp.Delivery), opts ...DialOption) (*RbMqClient, error)
- func NewAndInitRabbitServer(rbInfo RbInfo, opts ...DialOption) (*RbMqClient, error)
- func NewRabbitProduct(rbInfo RbInfo, callBack func(amqp.Delivery), opts ...DialOption) (*RbMqClient, error)
Constants ¶
View Source
const ( ReconnectDelay = 10 // 连接断开后多久重连 ResendDelay = 3 // 消息发送超时时间 )
Variables ¶
View Source
var ( ParamsError = errors.New("地址、路由和队列不能为空") CallBackError = errors.New("消费回调函数不能为空") )
Functions ¶
Types ¶
type ConsumeOpt ¶ added in v0.1.19
type DialOption ¶ added in v0.1.19
type DialOption interface {
// contains filtered or unexported methods
}
func WithConsumeOpt ¶ added in v0.1.19
func WithConsumeOpt(consumeOpt ConsumeOpt) DialOption
WithConsumeOpt Consume 参数
func WithDeadDurable ¶ added in v0.1.19
func WithDeadDurable(durable bool) DialOption
WithDeadDurable 死信队列是否持久化
func WithDeadExchangeOpt ¶ added in v0.1.19
func WithDeadExchangeOpt(exchangeOpt ExchangeDeclareOpt) DialOption
WithDeadExchangeOpt 死信交换机配置, 只有配置了死信队列才生效
func WithDeadQueueBindOpt ¶ added in v0.1.19
func WithDeadQueueBindOpt(queueBindOpt QueueBindOpt) DialOption
WithDeadQueueBindOpt 死信队列绑定配置, 只有配置了死信队列才生效
func WithDeadQueueOpt ¶ added in v0.1.19
func WithDeadQueueOpt(queueOpt QueueDeclareOpt) DialOption
WithDeadQueueOpt 死信队列配置, 只有配置了死信队列才生效
func WithExchangeOpt ¶ added in v0.1.19
func WithExchangeOpt(exchangeOpt ExchangeDeclareOpt) DialOption
WithExchangeOpt 交换机配置
func WithQueueBindOpt ¶ added in v0.1.19
func WithQueueBindOpt(queueBindOpt QueueBindOpt) DialOption
WithQueueBindOpt 队列绑定配置
func WithQueueOpt ¶ added in v0.1.19
func WithQueueOpt(queueOpt QueueDeclareOpt) DialOption
WithQueueOpt 队列配置
func WithReconnectDelay ¶ added in v0.1.19
func WithReconnectDelay(reconnectDelay time.Duration) DialOption
WithReconnectDelay 链接超时时间
func WithResendDelay ¶ added in v0.1.19
func WithResendDelay(resendDelay time.Duration) DialOption
WithResendDelay 发送超时时间
type ExchangeDeclareOpt ¶ added in v0.1.19
type QueueBindOpt ¶ added in v0.1.19
type QueueDeclareOpt ¶ added in v0.1.19
type RbMqClient ¶
type RbMqClient struct {
// contains filtered or unexported fields
}
func NewAndInitRabbitClient ¶
func NewAndInitRabbitClient(rbInfo RbInfo, callBack func(amqp.Delivery), opts ...DialOption) (*RbMqClient, error)
NewAndInitRabbitClient 新建消费端(消费消息)
func NewAndInitRabbitServer ¶
func NewAndInitRabbitServer(rbInfo RbInfo, opts ...DialOption) (*RbMqClient, error)
NewAndInitRabbitServer 新建服务端(发布消息)
func NewRabbitProduct ¶
func NewRabbitProduct(rbInfo RbInfo, callBack func(amqp.Delivery), opts ...DialOption) (*RbMqClient, error)
func (*RbMqClient) Consume ¶
func (rabbitProduct *RbMqClient) Consume(prefetchCount int)
Consume 消费消息 prefetchCount 预取数量,设置为1的话,可以实现性能高的服务器消费的数量多
func (*RbMqClient) InitRabbitProduct ¶
func (rabbitProduct *RbMqClient) InitRabbitProduct()
func (*RbMqClient) PublishMulti ¶
func (rabbitProduct *RbMqClient) PublishMulti(msgs [][]byte) (bool, int)
PublishMulti 返回发送是否全部成功和发送成功的数量
Click to show internal directories.
Click to hide internal directories.