mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 11:06:43 +08:00
getcd
This commit is contained in:
parent
cf82d3495e
commit
1fc0f0cb01
@ -2,17 +2,23 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
|
"Open_IM/pkg/common/trace_log"
|
||||||
|
"context"
|
||||||
"github.com/OpenIMSDK/getcdv3"
|
"github.com/OpenIMSDK/getcdv3"
|
||||||
"github.com/OpenIMSDK/open_utils/constant"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetConn(operationID, serviceName string) (*grpc.ClientConn, error) {
|
func GetConn(ctx context.Context, operationID, serviceName string) (conn *grpc.ClientConn, err error) {
|
||||||
conn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","),
|
defer func() {
|
||||||
|
trace_log.SetContextInfo(ctx, "GetConn", err, "serviceName", serviceName)
|
||||||
|
}()
|
||||||
|
conn = getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","),
|
||||||
serviceName, operationID, config.Config.Etcd.UserName, config.Config.Etcd.Password)
|
serviceName, operationID, config.Config.Etcd.UserName, config.Config.Etcd.Password)
|
||||||
if conn == nil {
|
if conn == nil {
|
||||||
return nil, constant.ErrGetRpcConn
|
return nil, constant.ErrRpcConn
|
||||||
}
|
}
|
||||||
return conn, nil
|
return conn, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user