batch

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// When batching pod creates, SlowStartInitialBatchSize is the size of the
	// initial batch. The size of each successive batch is twice the size of
	// the previous batch.
	SlowStartInitialBatchSize = 1

	// When batching requests, ConcurrentLimitDefault is the maximum number of
	// concurrent requests allowed to be in-flight at any given time.
	ConcurrentLimitDefault = 32
)

Variables

This section is empty.

Functions

func ConcurrentStartBatch

func ConcurrentStartBatch(ctx context.Context, count, limit int, fn func(index int) error) (int, error)

ConcurrentStartBatch calls fn for each index in [0, count), with at most limit calls in flight.

If there are any failures, all remaining batches are skipped after waiting for the in-flight batch to complete.

It returns the number of successful calls to the function.

func ConcurrentStartBatchDefault

func ConcurrentStartBatchDefault(ctx context.Context, count int, fn func(index int) error) (int, error)

func SlowStartBatch

func SlowStartBatch(count, initialBatchSize int, fn func(i int) error) (int, error)

SlowStartBatch tries to call the provided function a total of 'count' times, starting slow to check for errors, then speeding up if calls succeed.

It groups the calls into batches, starting with a group of initialBatchSize. Within each batch, it may call the function multiple times concurrently with its index.

If a whole batch succeeds, the next batch may get exponentially larger. If there are any failures in a batch, all remaining batches are skipped after waiting for the current batch to complete.

It returns the number of successful calls to the function.

func SlowStartBatchDefault

func SlowStartBatchDefault(count int, fn func(i int) error) (int, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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