mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
De-map device list positions in streaming tokens (#1642)
* De-map device list positions in streaming tokens * Fix lint error * Tweak toOffset
This commit is contained in:
parent
98ebbd01e5
commit
38318b0f16
5 changed files with 47 additions and 99 deletions
|
@ -73,15 +73,13 @@ func DeviceListCatchup(
|
|||
offset = sarama.OffsetOldest
|
||||
// Extract partition/offset from sync token
|
||||
// TODO: In a world where keyserver is sharded there will be multiple partitions and hence multiple QueryKeyChanges to make.
|
||||
logOffset := from.Log(DeviceListLogName)
|
||||
if logOffset != nil {
|
||||
partition = logOffset.Partition
|
||||
offset = logOffset.Offset
|
||||
if !from.DeviceListPosition.IsEmpty() {
|
||||
partition = from.DeviceListPosition.Partition
|
||||
offset = from.DeviceListPosition.Offset
|
||||
}
|
||||
var toOffset int64
|
||||
toOffset = sarama.OffsetNewest
|
||||
toLog := to.Log(DeviceListLogName)
|
||||
if toLog != nil && toLog.Offset > 0 {
|
||||
if toLog := to.DeviceListPosition; toLog.Partition == partition && toLog.Offset > 0 {
|
||||
toOffset = toLog.Offset
|
||||
}
|
||||
var queryRes api.QueryKeyChangesResponse
|
||||
|
@ -130,10 +128,10 @@ func DeviceListCatchup(
|
|||
}
|
||||
}
|
||||
// set the new token
|
||||
to.SetLog(DeviceListLogName, &types.LogPosition{
|
||||
to.DeviceListPosition = types.LogPosition{
|
||||
Partition: queryRes.Partition,
|
||||
Offset: queryRes.Offset,
|
||||
})
|
||||
}
|
||||
res.NextBatch = to.String()
|
||||
|
||||
return hasNew, nil
|
||||
|
|
|
@ -18,11 +18,9 @@ var (
|
|||
syncingUser = "@alice:localhost"
|
||||
emptyToken = types.StreamingToken{}
|
||||
newestToken = types.StreamingToken{
|
||||
Logs: map[string]*types.LogPosition{
|
||||
DeviceListLogName: {
|
||||
Offset: sarama.OffsetNewest,
|
||||
Partition: 0,
|
||||
},
|
||||
DeviceListPosition: types.LogPosition{
|
||||
Offset: sarama.OffsetNewest,
|
||||
Partition: 0,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue