1 Star 0 Fork 0

h79/goutils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
service.go 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
huqiuyun 提交于 2022-08-26 01:06 . 服务发现
package discovery
import (
"gitee.com/h79/goutils/discovery/config"
"gitee.com/h79/goutils/discovery/consul"
"gitee.com/h79/goutils/discovery/etcd"
"gitee.com/h79/goutils/discovery/local"
"gitee.com/h79/goutils/discovery/registry"
"gitee.com/h79/goutils/discovery/service"
"gitee.com/h79/goutils/discovery/zookeeper"
)
func NewService(cfg config.Config, points config.EndPoints, registry registry.Registry) (service.Service, error) {
if nsf, ok := _service[points.Type]; ok {
return nsf(cfg, points, registry)
}
switch points.Type {
case "consul":
return consul.NewService(cfg, points, registry)
case "zookeeper":
return zookeeper.NewService(cfg, points, registry)
case "etcd":
return etcd.NewService(cfg, points, registry)
default:
return local.NewService(cfg, points, registry)
}
}
/*
* example
//points, err := server.ReadEndPoints(endpointFileName)
//if err != nil {
// return nil, err
//}
//
//health, err := server.ReadHealth("")
//cfg := config.Config{
// Node: conf.Node,
// Server: conf.Server,
// HealthCheck: conf.HealthCheck,
// Meta: conf.Meta,
// Tags: conf.Tags,
//}
// register service to consul,zk,dubbo,etcd...
service, err := NewService(*conf, points)
if err != nil {
return nil, err
}
service.Start()
*/
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/h79/goutils.git
git@gitee.com:h79/goutils.git
h79
goutils
goutils
v1.6.11

搜索帮助