mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
config
This commit is contained in:
parent
41d94e2f40
commit
e1ee0500ea
@ -1,6 +1,7 @@
|
||||
package getcdv3
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
@ -48,6 +49,8 @@ func NewResolver(schema, etcdAddr, serviceName string) (*Resolver, error) {
|
||||
conn, err := grpc.DialContext(ctx, GetPrefix(schema, serviceName),
|
||||
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)),
|
||||
grpc.WithInsecure())
|
||||
log.Debug("", "etcd key ", GetPrefix(schema, serviceName), "value ", *r.grpcClientConn)
|
||||
|
||||
//conn, err := grpc.Dial(
|
||||
// GetPrefix(schema, serviceName),
|
||||
// grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)),
|
||||
@ -71,6 +74,7 @@ func GetConn(schema, etcdaddr, serviceName string) *grpc.ClientConn {
|
||||
r, ok := nameResolver[schema+serviceName]
|
||||
rwNameResolverMutex.RUnlock()
|
||||
if ok {
|
||||
log.Debug("", "etcd key ", schema+serviceName, "value ", *r.grpcClientConn, *r)
|
||||
return r.grpcClientConn
|
||||
}
|
||||
|
||||
@ -78,15 +82,18 @@ func GetConn(schema, etcdaddr, serviceName string) *grpc.ClientConn {
|
||||
r, ok = nameResolver[schema+serviceName]
|
||||
if ok {
|
||||
rwNameResolverMutex.Unlock()
|
||||
log.Debug("", "etcd key ", schema+serviceName, "value ", *r.grpcClientConn, *r)
|
||||
return r.grpcClientConn
|
||||
}
|
||||
|
||||
r, err := NewResolver(schema, etcdaddr, serviceName)
|
||||
if err != nil {
|
||||
log.Error("", "etcd failed ", schema, etcdaddr, serviceName)
|
||||
rwNameResolverMutex.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Debug("", "etcd key ", schema+serviceName, "value ", *r.grpcClientConn, *r)
|
||||
nameResolver[schema+serviceName] = r
|
||||
rwNameResolverMutex.Unlock()
|
||||
return r.grpcClientConn
|
||||
|
Loading…
x
Reference in New Issue
Block a user