1 Star 0 Fork 0

yzsunjianguo / sponge

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
consulcli.go 651 Bytes
一键复制 编辑 原始数据 按行查看 历史
yzsunjianguo 提交于 2024-02-08 14:53 . init
// Package consulcli is connecting to the consul service client.
package consulcli
import (
"fmt"
"github.com/hashicorp/consul/api"
)
// Init connecting to the consul service
// Note: If the WithConfig(*api.Config) parameter is set, the addr parameter is ignored!
func Init(addr string, opts ...Option) (*api.Client, error) {
o := defaultOptions()
o.apply(opts...)
if o.config != nil {
return api.NewClient(o.config)
}
if addr == "" {
return nil, fmt.Errorf("consul address cannot be empty")
}
return api.NewClient(&api.Config{
Address: addr,
Scheme: o.scheme,
WaitTime: o.waitTime,
Datacenter: o.datacenter,
})
}
Go
1
https://gitee.com/yzsunjianguo/sponge.git
git@gitee.com:yzsunjianguo/sponge.git
yzsunjianguo
sponge
sponge
v1.0.3

搜索帮助