mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
mongodriver test
This commit is contained in:
parent
4c92ee4a8a
commit
566c05bcef
@ -18,6 +18,6 @@ func saveUserChat(uid string, msg *pbMsg.MsgDataToMQ) error {
|
||||
pbSaveData := pbMsg.MsgDataToDB{}
|
||||
pbSaveData.MsgData = msg.MsgData
|
||||
log.NewInfo(msg.OperationID, "IncrUserSeq cost time", utils.GetCurrentTimestampByMill()-time)
|
||||
return db.DB.SaveUserChat(uid, pbSaveData.MsgData.SendTime, &pbSaveData)
|
||||
return db.DB.SaveUserChatMongo2(uid, pbSaveData.MsgData.SendTime, &pbSaveData)
|
||||
// return db.DB.SaveUserChatMongo2(uid, pbSaveData.MsgData.SendTime, &pbSaveData)
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *pbMsg.GetMaxAndMinSeq
|
||||
func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.PullMessageBySeqListReq) (*open_im_sdk.PullMessageBySeqListResp, error) {
|
||||
log.NewInfo(in.OperationID, "rpc PullMessageBySeqList is arriving", in.String())
|
||||
resp := new(open_im_sdk.PullMessageBySeqListResp)
|
||||
msgList, err := commonDB.DB.GetMsgBySeqList(in.UserID, in.SeqList, in.OperationID)
|
||||
// msgList, err := commonDB.DB.GetMsgBySeqListMongo2(in.UserID, in.SeqList, in.OperationID)
|
||||
//msgList, err := commonDB.DB.GetMsgBySeqList(in.UserID, in.SeqList, in.OperationID)
|
||||
msgList, err := commonDB.DB.GetMsgBySeqListMongo2(in.UserID, in.SeqList, in.OperationID)
|
||||
if err != nil {
|
||||
log.ErrorByKv("PullMessageBySeqList data error", in.OperationID, in.String())
|
||||
resp.ErrCode = 201
|
||||
|
@ -17,7 +17,7 @@ func (t *TimeTask) timedDeleteUserChat() {
|
||||
for i := 0; i < count; i++ {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
uid, _ := db.DB.MgoSkipUID(i)
|
||||
db.DB.DelUserChat(uid)
|
||||
db.DB.DelUserChatMongo2(uid)
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
@ -3,15 +3,15 @@ package db
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
// "context"
|
||||
// "fmt"
|
||||
// "context"
|
||||
// "fmt"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"gopkg.in/mgo.v2"
|
||||
"time"
|
||||
|
||||
//"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
// "go.mongodb.org/mongo-driver/mongo/options"
|
||||
// "go.mongodb.org/mongo-driver/mongo/options"
|
||||
|
||||
)
|
||||
|
||||
@ -36,7 +36,7 @@ func init() {
|
||||
initMysqlDB()
|
||||
// mongo init
|
||||
// "mongodb://sysop:moon@localhost/records"
|
||||
// uri := "mongodb://user:pass@sample.host:27017/?maxPoolSize=20&w=majority"
|
||||
//uri := "mongodb://user:pass@sample.host:27017/?maxPoolSize=20&w=majority"
|
||||
//uri := fmt.Sprintf("mongodb://%s:%s@%s/%s/?maxPoolSize=%d",
|
||||
// config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword,
|
||||
// config.Config.Mongo.DBAddress[0],config.Config.Mongo.DBDatabase,
|
||||
|
@ -65,7 +65,12 @@ func (d *DataBases) GetMinSeqFromMongo(uid string) (MinSeq uint32, err error) {
|
||||
//return MinSeq, nil
|
||||
}
|
||||
|
||||
func (d *DataBases) GetMinSeqFromMongo2(uid string) (MinSeq uint32, err error) {
|
||||
return 1, nil
|
||||
}
|
||||
|
||||
func (d *DataBases) GetMsgBySeqList(uid string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), uid, seqList)
|
||||
var hasSeqList []uint32
|
||||
singleCount := 0
|
||||
session := d.mgoSession.Clone()
|
||||
|
Loading…
x
Reference in New Issue
Block a user