File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -99,15 +99,13 @@ func (offset *SubscriptionOffset) GetCommit() info.ListOffsetInfo {
99
99
}
100
100
101
101
type offsetTracker struct {
102
- maxOffset uint64
103
- initOffset uint64
104
- list * skiplist.SkipList
102
+ maxOffset int64
103
+ list * skiplist.SkipList
105
104
}
106
105
107
106
func initOffset (initOffset uint64 ) * offsetTracker {
108
107
return & offsetTracker {
109
- initOffset : initOffset ,
110
- maxOffset : initOffset ,
108
+ maxOffset : int64 (initOffset ) - 1 ,
111
109
list : skiplist .New (skiplist .GreaterThanFunc (func (lhs , rhs interface {}) int {
112
110
v1 , _ := lhs .(uint64 )
113
111
v2 , _ := rhs .(uint64 )
@@ -123,7 +121,9 @@ func initOffset(initOffset uint64) *offsetTracker {
123
121
124
122
func (o * offsetTracker ) putOffset (offset uint64 ) {
125
123
o .list .Set (offset , offset )
126
- o .maxOffset , _ = o .list .Back ().Key ().(uint64 )
124
+ if int64 (offset ) > o .maxOffset {
125
+ o .maxOffset = int64 (offset )
126
+ }
127
127
}
128
128
129
129
func (o * offsetTracker ) commitOffset (offset uint64 ) {
@@ -132,10 +132,7 @@ func (o *offsetTracker) commitOffset(offset uint64) {
132
132
133
133
func (o * offsetTracker ) offsetToCommit () uint64 {
134
134
if o .list .Len () == 0 {
135
- if o .maxOffset == o .initOffset {
136
- return o .initOffset
137
- }
138
- return o .maxOffset + 1
135
+ return uint64 (o .maxOffset + 1 )
139
136
}
140
137
return o .list .Front ().Key ().(uint64 )
141
138
}
You can’t perform that action at this time.
0 commit comments