288
minTaskID int64,
289
maxTaskID int64,
290
>
) ([]*replicationspb.ReplicationTask, int64, error) {
ack_manager.go
291
>
if minTaskID > maxTaskID {
292
return nil, 0, serviceerror.NewUnavailable("min task ID > max task ID, probably due to shard re-balancing")
294
return nil, maxTaskID, nil
295
}
296
297
>
replicationTasks := make([]*replicationspb.ReplicationTask, 0, p.pageSize())
ack_manager.go
298
>
skippedTaskCount := 0
299
>
lastTaskID := maxTaskID // If no tasks are returned, then it means there are no tasks bellow maxTaskID.
300
>
iter := collection.NewPagingIterator(p.getReplicationTasksFn(ctx, minTaskID, maxTaskID, p.pageSize()))
301
>
// iter.HasNext() should be the last check to avoid extra page read in case if replicationTasks is already full.
302
>
for len(replicationTasks) < p.pageSize() && skippedTaskCount <= p.maxSkipTaskCount() && iter.HasNext() {
303
task, err := iter.Next()
304
if err != nil {