Ai
1 Star 0 Fork 0

SasukeBo/go-micro

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
options.go 1.82 KB
一键复制 编辑 原始数据 按行查看 历史
汪波 提交于 2023-02-23 10:27 +08:00 . fix: 替换包名
package stomp
import (
"context"
"time"
"gitee.com/sasukebo/go-micro/v4/broker"
)
// SubscribeHeaders sets headers for subscriptions
func SubscribeHeaders(h map[string]string) broker.SubscribeOption {
return setSubscribeOption(subscribeHeaderKey{}, h)
}
type subscribeContextKey struct{}
// SubscribeContext set the context for broker.SubscribeOption
func SubscribeContext(ctx context.Context) broker.SubscribeOption {
return setSubscribeOption(subscribeContextKey{}, ctx)
}
type ackSuccessKey struct{}
// AckOnSuccess will automatically acknowledge messages when no error is returned
func AckOnSuccess() broker.SubscribeOption {
return setSubscribeOption(ackSuccessKey{}, true)
}
// Durable sets a durable subscription
func Durable() broker.SubscribeOption {
return setSubscribeOption(durableQueueKey{}, true)
}
// Receipt requests a receipt for the delivery should be received
func Receipt(ct time.Duration) broker.PublishOption {
return setPublishOption(receiptKey{}, true)
}
// SuppressContentLength requests that send does not include a content length
func SuppressContentLength(ct time.Duration) broker.PublishOption {
return setPublishOption(suppressContentLengthKey{}, true)
}
// ConnectTimeout sets the connection timeout duration
func ConnectTimeout(ct time.Duration) broker.Option {
return setBrokerOption(connectTimeoutKey{}, ct)
}
// Auth sets the authentication information
func Auth(username string, password string) broker.Option {
return setBrokerOption(authKey{}, &authRecord{
username: username,
password: password,
})
}
// ConnectHeaders adds headers for the connection
func ConnectHeaders(h map[string]string) broker.Option {
return setBrokerOption(connectHeaderKey{}, h)
}
// VirtualHost adds host header to define the vhost
func VirtualHost(h string) broker.Option {
return setBrokerOption(vHostKey{}, h)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sasukebo/go-micro.git
git@gitee.com:sasukebo/go-micro.git
sasukebo
go-micro
go-micro
6e18eb58b836

搜索帮助