pool

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteBulkOperation

func ExecuteBulkOperation[R Reporter](ctx context.Context, keys []string, wantedWorkers int, failFast bool, operationName string, log *slog.Logger, opts []foptions.FacadeOption, fn func(context.Context, string, ...foptions.FacadeOption) (R, error)) ([]R, error)

ExecuteBulkOperation executes a bulk operation on a slice of keys with parallel workers Returns a slice of reports and an optional error

func ExecuteNTimes

func ExecuteNTimes[T any](ctx context.Context, n int, wantedWorkers int, failFast bool, fn func(context.Context, int) (T, error)) ([]T, error)

ExecuteNTimes runs fn for indices [0,n) with at most wantedWorkers concurrent goroutines, cancelling all work on context cancellation or the first error when failFast is true. It normalizes worker counts (clamping to [1,n]), allocates result/error slots up front, and returns a slice of outputs along with a joined error capturing every failure.

func ExecuteSlice

func ExecuteSlice[In any, Out any](ctx context.Context, in []In, wantedWorkers int, failFast bool, fn func(context.Context, In, int) (Out, error)) ([]Out, error)

ExecuteSlice maps a slice of inputs with concurrency, same semantics

Types

type Reporter

type Reporter interface {
	OK() bool
}

Reporter is an interface for operation reports that can indicate success/failure

type Reports

type Reports[T Reporter] struct {
	Items []T
}

Reports wraps a collection of reports and provides total counts

func (Reports[T]) Totals

func (r Reports[T]) Totals() (total int, oks int, noks int)

Totals returns the total count, successful count, and failed count

Jump to

Keyboard shortcuts

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