storj/satellite/metabase/rangedloop/provider.go
Erik van Velzen 3cf7ebfad0
satellite/metabase/rangedloop: database abstraction (#5337)
Add an abstraction rangedloop.SegmentProvider to fetch chunks of
segments from the metainfo database in parallel.

Part of https://github.com/storj/storj/issues/5223

Change-Id: Ife26467ea0c3be550bde0b05464ef1db62dd4d2a
2022-12-09 03:01:07 +01:00

24 lines
653 B
Go

// Copyright (C) 2022 Storj Labs, Inc.
// See LICENSE for copying information.
package rangedloop
import (
"context"
"storj.io/storj/satellite/metabase/segmentloop"
)
// RangeSplitter splits a source of segments into ranges,
// so that multiple segments can be processed concurrently.
// 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 {
Iterate(ctx context.Context, fn func([]segmentloop.Segment) error) error
}