parallelizer

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultParallelism is the default parallelism used in scheduler.
	DefaultParallelism int = 16
)

Variables

This section is empty.

Functions

func ParallelizeUntil

func ParallelizeUntil(ctx context.Context, workers, pieces int, doWorkPiece DoWorkPieceFunc, opts ...Options)

ParallelizeUntil is a framework that allows for parallelizing N independent pieces of work until done or the context is canceled.

func WithChunkSize

func WithChunkSize(c int) func(*options)

WithChunkSize allows to set chunks of work items to the workers, rather than processing one by one. It is recommended to use this option if the number of pieces significantly higher than the number of workers and the work done for each item is small.

Types

type Config

type Config struct {
	Config config.Config
}

func DefaultConfig

func DefaultConfig() *Config

type DoWorkPieceFunc

type DoWorkPieceFunc func(int)

type Options

type Options func(*options)

type Parallelizer

type Parallelizer interface {
	Init(context.Context, int) error
}

func New

func New(_ context.Context, cfg *Config) Parallelizer

Jump to

Keyboard shortcuts

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