mirror of
https://github.com/zhufuyi/sponge.git
synced 2025-10-11 11:40:16 +08:00
adjustment code
This commit is contained in:
@@ -15,12 +15,12 @@ import (
|
||||
"github.com/zhufuyi/sponge/pkg/servicerd/registry/nacos"
|
||||
)
|
||||
|
||||
// RegisterServers 注册app服务
|
||||
// RegisterServers register for the app service
|
||||
func RegisterServers() []app.IServer {
|
||||
var cfg = config.Get()
|
||||
var servers []app.IServer
|
||||
|
||||
// 创建grpc服务
|
||||
// creating grpc service
|
||||
grpcAddr := ":" + strconv.Itoa(cfg.Grpc.Port)
|
||||
grpcRegistry, grpcInstance := registryService("grpc", cfg.App.Host, cfg.Grpc.Port)
|
||||
grpcServer := server.NewGRPCServer(grpcAddr,
|
||||
@@ -38,7 +38,7 @@ func registryService(scheme string, host string, port int) (registry.Registry, *
|
||||
cfg := config.Get()
|
||||
|
||||
switch cfg.App.RegistryDiscoveryType {
|
||||
// 使用consul注册服务
|
||||
// registering service with consul
|
||||
case "consul":
|
||||
iRegistry, instance, err := consul.NewRegistry(
|
||||
cfg.Consul.Addr,
|
||||
@@ -50,7 +50,7 @@ func registryService(scheme string, host string, port int) (registry.Registry, *
|
||||
panic(err)
|
||||
}
|
||||
return iRegistry, instance
|
||||
// 使用etcd注册服务
|
||||
// registering service with etcd
|
||||
case "etcd":
|
||||
iRegistry, instance, err := etcd.NewRegistry(
|
||||
cfg.Etcd.Addrs,
|
||||
@@ -62,7 +62,7 @@ func registryService(scheme string, host string, port int) (registry.Registry, *
|
||||
panic(err)
|
||||
}
|
||||
return iRegistry, instance
|
||||
// 使用nacos注册服务
|
||||
// registering service with nacos
|
||||
case "nacos":
|
||||
iRegistry, instance, err := nacos.NewRegistry(
|
||||
cfg.NacosRd.IPAddr,
|
||||
|
Reference in New Issue
Block a user