1 Star 0 Fork 0

openfaiss/nats-queue-worker

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
nats_config.go 880 Bytes
一键复制 编辑 原始数据 按行查看 历史
openfaiss 提交于 2023-10-26 17:38 +08:00 . first commit
package handler
import (
"os"
"time"
"gitee.com/openfaiss/nats-queue-worker/nats"
)
type NATSConfig interface {
GetClientID() string
GetMaxReconnect() int
GetReconnectDelay() time.Duration
}
type DefaultNATSConfig struct {
maxReconnect int
reconnectDelay time.Duration
}
func NewDefaultNATSConfig(maxReconnect int, reconnectDelay time.Duration) DefaultNATSConfig {
return DefaultNATSConfig{maxReconnect, reconnectDelay}
}
// GetClientID returns the ClientID assigned to this producer/consumer.
func (DefaultNATSConfig) GetClientID() string {
val, _ := os.Hostname()
return getClientID(val)
}
func (c DefaultNATSConfig) GetMaxReconnect() int {
return c.maxReconnect
}
func (c DefaultNATSConfig) GetReconnectDelay() time.Duration {
return c.reconnectDelay
}
func getClientID(hostname string) string {
return "faas-publisher-" + nats.GetClientID(hostname)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openfaiss/nats-queue-worker.git
git@gitee.com:openfaiss/nats-queue-worker.git
openfaiss
nats-queue-worker
nats-queue-worker
b232b79616c6

搜索帮助