test-errcode
wangchuxiao 2 years ago
parent c2fbcd1f22
commit cd6c056e73

@ -4,7 +4,7 @@ go 1.15
require (
firebase.google.com/go v3.13.0+incompatible
github.com/OpenIMSDK/getcdv3 v1.0.3
github.com/OpenIMSDK/getcdv3 v1.0.4
github.com/OpenIMSDK/open_utils v1.0.8
github.com/Shopify/sarama v1.32.0
github.com/alibabacloud-go/darabonba-openapi v0.1.11

@ -393,6 +393,8 @@ github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6Xge
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/OpenIMSDK/getcdv3 v1.0.3 h1:3/j92MuDPFhAJYBy/ht0qnybdaaCezefF1pMTClvvq4=
github.com/OpenIMSDK/getcdv3 v1.0.3/go.mod h1:ZvsBwAjOZZr7HBF3SytJaHCltuOfBKbM1vLSCjut7kw=
github.com/OpenIMSDK/getcdv3 v1.0.4 h1:wKpLcp1gbLbh+fa7b5iCL4fTBLm87hB0+p0ZQMg9tK8=
github.com/OpenIMSDK/getcdv3 v1.0.4/go.mod h1:ZvsBwAjOZZr7HBF3SytJaHCltuOfBKbM1vLSCjut7kw=
github.com/OpenIMSDK/open_log v1.0.0 h1:ZQ908aWgPqfHOfkQ/oFSV20AZdRwPw+sZjC/sAPd5cA=
github.com/OpenIMSDK/open_log v1.0.0/go.mod h1:qWvqF4iT2qBAP1eGGbinc0aAng1Y25X8A9Si1WS3oB4=
github.com/OpenIMSDK/open_utils v1.0.1/go.mod h1:PPRayByXnfu8PR5Xv9wzUMBrm1BV3y7s29GGg8ae47s=

@ -16,8 +16,8 @@ import (
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/common/tracelog"
"fmt"
"github.com/OpenIMSDK/getcdv3"
"Open_IM/pkg/getcdv3"
pbConversation "Open_IM/pkg/proto/conversation"
pbGroup "Open_IM/pkg/proto/group"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
@ -42,6 +42,9 @@ type groupServer struct {
etcdSchema string
etcdAddr []string
controller.GroupInterface
userRpc pbUser.UserClient
conversationRpc pbConversation.ConversationClient
}
func NewGroupServer(port int) *groupServer {
@ -52,12 +55,29 @@ func NewGroupServer(port int) *groupServer {
etcdSchema: config.Config.Etcd.EtcdSchema,
etcdAddr: config.Config.Etcd.EtcdAddr,
}
ttl := 10
etcdClient, err := getcdv3.NewEtcdConn(g.rpcRegisterName, strings.Join(g.etcdAddr, ","), config.Config.RpcRegisterIP, config.Config.Etcd.UserName, config.Config.Etcd.Password, port, ttl)
if err != nil {
panic("NewEtcdConn failed" + err.Error())
}
err = etcdClient.RegisterEtcd("", g.rpcRegisterName)
if err != nil {
panic("NewEtcdConn failed" + err.Error())
}
etcdClient.SetDefaultEtcdConfig(config.Config.RpcRegisterName.OpenImUserName, config.Config.RpcPort.OpenImUserPort)
conn := etcdClient.GetConn("", config.Config.RpcRegisterName.OpenImUserName)
g.userRpc = pbUser.NewUserClient(conn)
etcdClient.SetDefaultEtcdConfig(config.Config.RpcRegisterName.OpenImConversationName, config.Config.RpcPort.OpenImConversationPort)
conn = etcdClient.GetConn("", config.Config.RpcRegisterName.OpenImConversationName)
g.conversationRpc = pbConversation.NewConversationClient(conn)
//mysql init
var mysql relation.Mysql
var mongo unrelation.Mongo
var groupModel table.GroupModel
var redis cache.RedisClient
err := mysql.InitConn().AutoMigrateModel(&groupModel)
err = mysql.InitConn().AutoMigrateModel(&groupModel)
if err != nil {
panic("db init err:" + err.Error())
}
@ -870,19 +890,6 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
}
if req.GroupInfoForSet.Notification != "" {
//get group member user id
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: tracelog.GetOperationID(ctx), GroupID: req.GroupInfoForSet.GroupID}
etcdConn, err := getcdv3.GetConn(ctx, config.Config.RpcRegisterName.OpenImCacheName)
if err != nil {
return nil, err
}
client := pbCache.NewCacheClient(etcdConn)
cacheResp, err := client.GetGroupMemberIDListFromCache(ctx, getGroupMemberIDListFromCacheReq)
if err != nil {
return nil, err
}
if err = constant.CommonResp2Err(cacheResp.CommonResp); err != nil {
return nil, err
}
var conversationReq pbConversation.ModifyConversationFieldReq
conversation := pbConversation.Conversation{
OwnerUserID: tracelog.GetOpUserID(ctx),
@ -895,12 +902,8 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
conversationReq.FieldType = constant.FieldGroupAtType
conversation.GroupAtType = constant.GroupNotification
conversationReq.UserIDList = cacheResp.UserIDList
nEtcdConn, err := getcdv3.GetConn(ctx, config.Config.RpcRegisterName.OpenImConversationName)
if err != nil {
return nil, err
}
nClient := pbConversation.NewConversationClient(nEtcdConn)
conversationReply, err := nClient.ModifyConversationField(context.Background(), &conversationReq)
_, err := s.conversationRpc.ModifyConversationField(ctx, &conversationReq)
tracelog.SetCtxInfo(ctx, "ModifyConversationField", err, "req", &conversationReq, "resp", conversationReply)
}
return resp, nil

@ -1,35 +0,0 @@
package getcdv3
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/tracelog"
"context"
"github.com/OpenIMSDK/getcdv3"
"google.golang.org/grpc"
"strings"
)
func GetDefaultConn(arg1, arg2, arg3, arg4 string) *grpc.ClientConn {
return getcdv3.GetConn(arg1, arg2, arg3, arg4, config.Config.Etcd.UserName, config.Config.Etcd.Password)
}
func GetConn(ctx context.Context, serviceName string) (conn *grpc.ClientConn, err error) {
defer func() {
tracelog.SetCtxInfo(ctx, "GetConn", err, "serviceName", serviceName)
}()
conn = getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","),
serviceName, tracelog.GetOperationID(ctx), config.Config.Etcd.UserName, config.Config.Etcd.Password)
if conn == nil {
return nil, constant.ErrInternalServer
}
return conn, nil
}
func GetDefaultGatewayConn4Unique(schema, addr, operationID string) []*grpc.ClientConn {
return nil
}
func RegisterEtcd(schema, etcdAddr, myHost string, myPort int, serviceName string, ttl int, operationID string) error {
return getcdv3.RegisterEtcd(schema, etcdAddr, myHost, myPort, serviceName, ttl, operationID)
}
Loading…
Cancel
Save