Documentation ¶
Index ¶
- type CallbackObserver
- func (c *CallbackObserver) Finish(ctx context.Context) error
- func (c *CallbackObserver) Fork(ctx context.Context) (rangedloop.Partial, error)
- func (c *CallbackObserver) Join(ctx context.Context, partial rangedloop.Partial) error
- func (c *CallbackObserver) Process(ctx context.Context, segments []segmentloop.Segment) error
- func (c *CallbackObserver) Start(ctx context.Context, time time.Time) error
- type CountObserver
- func (c *CountObserver) Finish(ctx context.Context) error
- func (c *CountObserver) Fork(ctx context.Context) (rangedloop.Partial, error)
- func (c *CountObserver) Join(ctx context.Context, partial rangedloop.Partial) error
- func (c *CountObserver) Process(ctx context.Context, segments []segmentloop.Segment) error
- func (c *CountObserver) Start(ctx context.Context, time time.Time) error
- type InfiniteSegmentProvider
- type RangeSplitter
- type SegmentProvider
- type SleepObserver
- func (c *SleepObserver) Finish(ctx context.Context) error
- func (c *SleepObserver) Fork(ctx context.Context) (rangedloop.Partial, error)
- func (c *SleepObserver) Join(ctx context.Context, partial rangedloop.Partial) error
- func (c *SleepObserver) Process(ctx context.Context, segments []segmentloop.Segment) error
- func (c *SleepObserver) Start(ctx context.Context, time time.Time) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallbackObserver ¶ added in v1.71.1
type CallbackObserver struct { OnProcess func(context.Context, []segmentloop.Segment) error OnStart func(context.Context, time.Time) error OnFork func(context.Context) (rangedloop.Partial, error) OnJoin func(context.Context, rangedloop.Partial) error OnFinish func(context.Context) error }
CallbackObserver can be used to easily attach logic to the ranged segment loop during tests.
func (*CallbackObserver) Finish ¶ added in v1.71.1
func (c *CallbackObserver) Finish(ctx context.Context) error
Finish executes a callback at ranged segment loop end.
func (*CallbackObserver) Fork ¶ added in v1.71.1
func (c *CallbackObserver) Fork(ctx context.Context) (rangedloop.Partial, error)
Fork executes a callback for every segment range at ranged segment loop fork stage.
func (*CallbackObserver) Join ¶ added in v1.71.1
func (c *CallbackObserver) Join(ctx context.Context, partial rangedloop.Partial) error
Join executes a callback for every segment range at ranged segment loop join stage.
func (*CallbackObserver) Process ¶ added in v1.71.1
func (c *CallbackObserver) Process(ctx context.Context, segments []segmentloop.Segment) error
Process executes a callback for every batch of segment in the ranged segment loop.
type CountObserver ¶
type CountObserver struct {
NumSegments int
}
CountObserver is a subscriber to the ranged segment loop which counts the number of segments.
func (*CountObserver) Finish ¶
func (c *CountObserver) Finish(ctx context.Context) error
Finish is the callback for ranged segment loop end.
func (*CountObserver) Fork ¶
func (c *CountObserver) Fork(ctx context.Context) (rangedloop.Partial, error)
Fork splits the observer to count ranges of segments.
func (*CountObserver) Join ¶
func (c *CountObserver) Join(ctx context.Context, partial rangedloop.Partial) error
Join adds the count of all the ranges together.
func (*CountObserver) Process ¶
func (c *CountObserver) Process(ctx context.Context, segments []segmentloop.Segment) error
Process counts the size of a batch of segments.
type InfiniteSegmentProvider ¶ added in v1.71.1
type InfiniteSegmentProvider struct { }
InfiniteSegmentProvider allow to iterate indefinitely to test service cancellation.
func (*InfiniteSegmentProvider) CreateRanges ¶ added in v1.71.1
func (m *InfiniteSegmentProvider) CreateRanges(nRanges int, batchSize int) (segmentsProviders []rangedloop.SegmentProvider, err error)
CreateRanges splits the segments into equal ranges.
func (*InfiniteSegmentProvider) Iterate ¶ added in v1.71.1
func (m *InfiniteSegmentProvider) Iterate(ctx context.Context, fn func([]segmentloop.Segment) error) error
Iterate allows to loop over the segments stored in the provider.
type RangeSplitter ¶
type RangeSplitter struct {
Segments []segmentloop.Segment
}
RangeSplitter allows to iterate over segments from an in-memory source.
func (*RangeSplitter) CreateRanges ¶
func (m *RangeSplitter) CreateRanges(nRanges int, batchSize int) ([]rangedloop.SegmentProvider, error)
CreateRanges splits the segments into equal ranges.
type SegmentProvider ¶
type SegmentProvider struct { Segments []segmentloop.Segment // contains filtered or unexported fields }
SegmentProvider allows to iterate over segments from an in-memory source.
func (*SegmentProvider) Iterate ¶
func (m *SegmentProvider) Iterate(ctx context.Context, fn func([]segmentloop.Segment) error) error
Iterate allows to loop over the segments stored in the provider.
type SleepObserver ¶
SleepObserver is a subscriber to the segment loop which sleeps for every batch.
func (*SleepObserver) Finish ¶
func (c *SleepObserver) Finish(ctx context.Context) error
Finish is the callback for segment loop end.
func (*SleepObserver) Fork ¶
func (c *SleepObserver) Fork(ctx context.Context) (rangedloop.Partial, error)
Fork splits the observer to process a segment range.
func (*SleepObserver) Join ¶
func (c *SleepObserver) Join(ctx context.Context, partial rangedloop.Partial) error
Join is a noop.
func (*SleepObserver) Process ¶
func (c *SleepObserver) Process(ctx context.Context, segments []segmentloop.Segment) error
Process sleeps for every batch of segments to simulate execution time.