rangedlooptest

package
v1.119.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

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, []rangedloop.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

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 []rangedloop.Segment) error

Process executes a callback for every batch of segment in the ranged segment loop.

func (*CallbackObserver) Start added in v1.71.1

func (c *CallbackObserver) Start(ctx context.Context, time time.Time) error

Start executes a callback at ranged segment loop start.

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

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 []rangedloop.Segment) error

Process counts the size of a batch of segments.

func (*CountObserver) Start

func (c *CountObserver) Start(ctx context.Context, time time.Time) error

Start is the callback for segment loop start.

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([]rangedloop.Segment) error) error

Iterate allows to loop over the segments stored in the provider.

func (*InfiniteSegmentProvider) Range added in v1.74.1

Range returns range which is processed by this provider.

type RangeSplitter

type RangeSplitter struct {
	Segments []rangedloop.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 []rangedloop.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([]rangedloop.Segment) error) error

Iterate allows to loop over the segments stored in the provider.

func (*SegmentProvider) Range added in v1.74.1

Range returns range which is processed by this provider.

type SleepObserver

type SleepObserver struct {
	Duration time.Duration
}

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

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 []rangedloop.Segment) error

Process sleeps for every batch of segments to simulate execution time.

func (*SleepObserver) Start

func (c *SleepObserver) Start(ctx context.Context, time time.Time) error

Start is the callback for segment loop start.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL