2022-12-08 14:27:21 +00:00
|
|
|
// Copyright (C) 2022 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package rangedloop
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
2022-12-09 02:01:07 +00:00
|
|
|
// RangeSplitter splits a source of segments into ranges,
|
|
|
|
// so that multiple segments can be processed concurrently.
|
2022-12-08 14:27:21 +00:00
|
|
|
// It usually abstracts over a database.
|
|
|
|
// It is a subcomponent of the ranged segment loop.
|
|
|
|
type RangeSplitter interface {
|
|
|
|
CreateRanges(nRanges int, batchSize int) ([]SegmentProvider, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SegmentProvider iterates through a range of segments.
|
|
|
|
type SegmentProvider interface {
|
2023-02-03 10:04:53 +00:00
|
|
|
Range() UUIDRange
|
2023-05-09 12:13:19 +01:00
|
|
|
Iterate(ctx context.Context, fn func([]Segment) error) error
|
2022-12-08 14:27:21 +00:00
|
|
|
}
|