feat: multiple address

pull/1775/head
AndrewZuo01 2 years ago
parent 6aaf79c517
commit 898dde9bb8

@ -16,6 +16,7 @@ package api
import ( import (
"context" "context"
"fmt"
"net/http" "net/http"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
@ -43,7 +44,7 @@ import (
) )
func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.UniversalClient) *gin.Engine { func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.UniversalClient) *gin.Engine {
discov.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials())) // 默认RPC中间件 discov.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin"))) // 默认RPC中间件
gin.SetMode(gin.ReleaseMode) gin.SetMode(gin.ReleaseMode)
r := gin.New() r := gin.New()
if v, ok := binding.Validator.Engine().(*validator.Validate); ok { if v, ok := binding.Validator.Engine().(*validator.Validate); ok {

@ -75,6 +75,7 @@ func NewConnManager() (*ConnManager, error) {
func (cm *ConnManager) GetConns(ctx context.Context, func (cm *ConnManager) GetConns(ctx context.Context,
serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error) { serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error) {
if conns, exists := cm.conns[serviceName]; exists { if conns, exists := cm.conns[serviceName]; exists {
return conns, nil return conns, nil
} }

Loading…
Cancel
Save