2024-05-27 15:15:23 +08:00

32 lines
600 B
Go

package dataver
import "github.com/openimsdk/tools/utils/datautil"
type SyncResult struct {
Version uint
DeleteEID []string
Changes []string
Full bool
}
func NewSyncResult(wl *WriteLog, fullIDs []string) *SyncResult {
var findEIDs []string
var res SyncResult
if wl.Full() {
res.Changes = fullIDs
res.Full = true
} else {
idSet := datautil.SliceSet(fullIDs)
for _, l := range wl.Logs {
if l.Deleted {
res.DeleteEID = append(res.DeleteEID, l.EID)
} else {
if _, ok := idSet[l.EID]; ok {
findEIDs = append(findEIDs, l.EID)
}
}
}
}
return &res
}