test-errcode
wangchuxiao 2 years ago
parent 52b079a582
commit 945b638d4d

@ -15,7 +15,6 @@ func Call[A, B, C any](
client func(ctx context.Context) (C, error),
c *gin.Context,
) {
log.ZDebug(c, "before bind")
var req A
if err := c.BindJSON(&req); err != nil {
log.ZWarn(c, "gin bind json error", err, "req", req)
@ -29,14 +28,12 @@ func Call[A, B, C any](
return
}
}
log.ZDebug(c, "before get grpc conn")
cli, err := client(c)
if err != nil {
log.ZError(c, "get conn error", err, "req", req)
apiresp.GinError(c, errs.ErrInternalServer.Wrap(err.Error())) // 获取RPC连接失败
return
}
log.ZDebug(c, "before call rpc")
data, err := rpc(cli, c, &req)
if err != nil {
log.ZError(c, "rpc call error", err, "req", req)

@ -268,7 +268,6 @@ func (c *msgCache) GetMessagesBySeq(ctx context.Context, conversationID string,
for i, v := range result {
cmd := v.(*redis.StringCmd)
if cmd.Err() != nil {
log.ZWarn(ctx, "get msg from cache failed", cmd.Err(), "cmd", cmd.Val())
failedSeqs = append(failedSeqs, seqs[i])
} else {
msg := sdkws.MsgData{}

@ -519,6 +519,9 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, conversation
log.ZError(ctx, "get message from redis exception", err, conversationID, seqs)
}
}
if len(failedSeqs) != 0 {
log.ZDebug(ctx, "get message from redis failed", err, "seqs", seqs)
}
// get from cache or db
prome.Add(prome.MsgPullFromRedisSuccessCounter, len(successMsgs))
if len(failedSeqs) > 0 {

@ -154,11 +154,6 @@ func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(ctx context.Context, docID strin
if err != nil {
return nil, nil, errs.Wrap(err)
}
// result, err := m.MsgCollection.Find(ctx, bson.M{"doc_id": docID, "msgs": bson.M{"$slice": []int64{beginIndex, num}}})
// if err != nil {
// return nil, nil, err
// }
var msgInfos []table.MsgInfoModel
if err := cursor.All(ctx, &msgInfos); err != nil {
return nil, nil, err
@ -166,12 +161,14 @@ func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(ctx context.Context, docID strin
if len(msgInfos) < 1 {
return nil, nil, errs.ErrRecordNotFound.Wrap("mongo GetMsgBySeqIndex failed, len is 0")
}
log.ZDebug(ctx, "msgInfos", "num", len(msgInfos))
for _, v := range msgInfos {
var msg sdkws.MsgData
if err := proto.Unmarshal(v.Msg, &msg); err != nil {
return nil, nil, err
}
if msg.Seq >= beginSeq && msg.Seq <= endSeq {
log.ZDebug(ctx, "find msg", "msg", &msg)
msgs = append(msgs, &msg)
seqs = append(seqs, msg.Seq)
} else {

Loading…
Cancel
Save