当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
2 Star 0 Fork 1

JUMEI_ARCH / go-plugins
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
options.go 1.51 KB
一键复制 编辑 原始数据 按行查看 历史
Andrew 提交于 2018-09-25 08:49 . RabbitMQ prefetch count and global flag
package rabbitmq
import (
"context"
"github.com/micro/go-micro/broker"
)
type durableQueueKey struct{}
type headersKey struct{}
type prefetchCountKey struct{}
type prefetchGlobalKey struct{}
type exchangeKey struct{}
// DurableQueue creates a durable queue when subscribing.
func DurableQueue() broker.SubscribeOption {
return func(o *broker.SubscribeOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, durableQueueKey{}, true)
}
}
// Headers adds headers used by the headers exchange
func Headers(h map[string]interface{}) broker.SubscribeOption {
return func(o *broker.SubscribeOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, headersKey{}, h)
}
}
// Exchange is an option to set the Exchange
func Exchange(e string) broker.Option {
return func(o *broker.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, exchangeKey{}, e)
}
}
// PrefetchCount ...
func PrefetchCount(c int) broker.Option {
return func(o *broker.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, prefetchCountKey{}, c)
}
}
// PrefetchGlobal creates a durable queue when subscribing.
func PrefetchGlobal() broker.Option {
return func(o *broker.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, prefetchGlobalKey{}, true)
}
}
Go
1
https://gitee.com/JMArch/go-plugins.git
git@gitee.com:JMArch/go-plugins.git
JMArch
go-plugins
go-plugins
v0.14.1

搜索帮助

14c37bed 8189591 565d56ea 8189591