|
|
|
@ -99,7 +99,12 @@ func (s *friendServer) AddBlacklist(ctx context.Context, req *pbFriend.AddBlackl
|
|
|
|
|
}
|
|
|
|
|
log.NewInfo(req.CommID.OperationID, "AddBlacklist rpc ok ", req.CommID.FromUserID, req.CommID.ToUserID)
|
|
|
|
|
reqAddBlackUserToCache := &pbCache.AddBlackUserToCacheReq{UserID: req.CommID.FromUserID, BlackUserID: req.CommID.ToUserID, OperationID: req.CommID.OperationID}
|
|
|
|
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
|
|
|
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.CommID.OperationID)
|
|
|
|
|
if etcdConn == nil {
|
|
|
|
|
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
|
|
|
log.NewError(req.CommID.OperationID, errMsg)
|
|
|
|
|
return &pbFriend.AddBlacklistResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
|
}
|
|
|
|
|
cacheClient := pbCache.NewCacheClient(etcdConn)
|
|
|
|
|
cacheResp, err := cacheClient.AddBlackUserToCache(context.Background(), reqAddBlackUserToCache)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -263,7 +268,12 @@ func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddF
|
|
|
|
|
}
|
|
|
|
|
// cache rpc
|
|
|
|
|
addFriendToCacheReq := &pbCache.AddFriendToCacheReq{OperationID: req.CommID.OperationID}
|
|
|
|
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
|
|
|
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.CommID.OperationID)
|
|
|
|
|
if etcdConn == nil {
|
|
|
|
|
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
|
|
|
log.NewError(req.CommID.OperationID, errMsg)
|
|
|
|
|
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
|
}
|
|
|
|
|
client := pbCache.NewCacheClient(etcdConn)
|
|
|
|
|
addFriendToCacheReq.UserID = req.CommID.ToUserID
|
|
|
|
|
addFriendToCacheReq.FriendID = req.CommID.FromUserID
|
|
|
|
@ -318,7 +328,12 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFri
|
|
|
|
|
}
|
|
|
|
|
log.NewInfo(req.CommID.OperationID, "DeleteFriend rpc ok")
|
|
|
|
|
reduceFriendFromCache := &pbCache.ReduceFriendFromCacheReq{OperationID: req.CommID.OperationID, UserID: req.CommID.FromUserID, FriendID: req.CommID.ToUserID}
|
|
|
|
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
|
|
|
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.CommID.OperationID)
|
|
|
|
|
if etcdConn == nil {
|
|
|
|
|
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
|
|
|
log.NewError(req.CommID.OperationID, errMsg)
|
|
|
|
|
return &pbFriend.DeleteFriendResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
|
}
|
|
|
|
|
client := pbCache.NewCacheClient(etcdConn)
|
|
|
|
|
respPb, err := client.ReduceFriendFromCache(context.Background(), reduceFriendFromCache)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -399,7 +414,13 @@ func (s *friendServer) RemoveBlacklist(ctx context.Context, req *pbFriend.Remove
|
|
|
|
|
}
|
|
|
|
|
log.NewInfo(req.CommID.OperationID, "rpc RemoveBlacklist ok ")
|
|
|
|
|
reqReduceBlackUserFromCache := &pbCache.ReduceBlackUserFromCacheReq{UserID: req.CommID.FromUserID, BlackUserID: req.CommID.ToUserID, OperationID: req.CommID.OperationID}
|
|
|
|
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
|
|
|
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.CommID.OperationID)
|
|
|
|
|
if etcdConn == nil {
|
|
|
|
|
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
|
|
|
log.NewError(req.CommID.OperationID, errMsg)
|
|
|
|
|
return &pbFriend.RemoveBlacklistResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cacheClient := pbCache.NewCacheClient(etcdConn)
|
|
|
|
|
cacheResp, err := cacheClient.ReduceBlackUserFromCache(context.Background(), reqReduceBlackUserFromCache)
|
|
|
|
|
if err != nil {
|
|
|
|
|