new mongo

This commit is contained in:
withchao 2024-05-24 18:11:48 +08:00
parent e99eaf9146
commit 2f97933f6c
2 changed files with 46 additions and 6 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/openimsdk/tools/errs" "github.com/openimsdk/tools/errs"
"github.com/openimsdk/tools/utils/datautil" "github.com/openimsdk/tools/utils/datautil"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"time" "time"
) )
@ -16,12 +17,13 @@ const (
) )
type WriteLog struct { type WriteLog struct {
DID string `bson:"d_id"` ID primitive.ObjectID `bson:"_id"`
Logs []Elem `bson:"logs"` DID string `bson:"d_id"`
Version uint `bson:"version"` Logs []Elem `bson:"logs"`
Deleted uint `bson:"deleted"` Version uint `bson:"version"`
LastUpdate time.Time `bson:"last_update"` Deleted uint `bson:"deleted"`
LogLen int `bson:"log_len"` LastUpdate time.Time `bson:"last_update"`
LogLen int `bson:"log_len"`
} }
func (w *WriteLog) Full() bool { func (w *WriteLog) Full() bool {

View File

@ -0,0 +1,38 @@
package dataver
/*
UserIDs 顺序
前500顺序
1,2,3,4,5,6,7,8,9
1,3,5,7,8,9
1.sdk添加一个表记录 docID(后续换名字), version
2.sdk同步先计算idHashapi调用参数idHash, docID, version
3.服务器先判断version变更记录没有直接返回同步成功
有变更先查版本变更记录在查前500id变更记录只保留前500id中的
根据前500id计算idHash不一致返回会全量id不反悔删除id
全量同步有标识只返回全量id
变更记录只包含id不包括详细信息
4.sdk通过变更记录同步数据不一致进行重试
*/