refactor(core): select discovery backend from configured type

This commit is contained in:
dsx137 2026-07-21 15:06:28 +08:00
parent a2553f2028
commit d11ea11552
2 changed files with 10 additions and 8 deletions

5
.gitignore vendored
View File

@ -387,4 +387,7 @@ Sessionx.vim
# End of https://www.toptal.com/developers/gitignore/api/go,git,vim,tags,test,emacs,backup,jetbrains
.idea
dist/
dist/
.omo
.sisyphus

View File

@ -15,6 +15,7 @@
package discoveryregister
import (
"strings"
"time"
"google.golang.org/grpc"
@ -39,16 +40,14 @@ func NewDiscoveryRegister(discovery *config.Discovery, watchNames []string) (dis
}
switch discoveryType {
case config.KUBERNETES:
namespace := discovery.Kubernetes.Namespace
if namespace == "" {
namespace = "default"
for i := range watchNames {
watchNames[i] = strings.Split(watchNames[i], ":")[0]
}
return kubernetes.NewConnManager(
namespace,
watchNames,
return kubernetes.NewConnManager(discovery.Kubernetes.Namespace, watchNames,
grpc.WithDefaultCallOptions(
grpc.MaxCallSendMsgSize(20*1024*1024),
grpc.MaxCallSendMsgSize(1024*1024*20),
),
grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"}`),
)
case config.ETCD:
return etcd.NewSvcDiscoveryRegistry(