mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-05 11:52:10 +08:00
new mongo
This commit is contained in:
parent
e99eaf9146
commit
2f97933f6c
@ -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 {
|
||||||
|
|||||||
38
pkg/common/db/dataver/todo.go
Normal file
38
pkg/common/db/dataver/todo.go
Normal 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同步,先计算idHash,api调用参数idHash, docID, version
|
||||||
|
3.服务器先判断version变更记录,没有直接返回同步成功。
|
||||||
|
有变更,先查版本变更记录,在查前500id,变更记录只保留前500id中的
|
||||||
|
根据前500id计算idHash,不一致返回会全量id,不反悔删除id
|
||||||
|
全量同步有标识,只返回全量id
|
||||||
|
变更记录只包含id,不包括详细信息。
|
||||||
|
4.sdk通过变更记录,同步数据不一致进行重试。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
Loading…
x
Reference in New Issue
Block a user