parallel

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package parallel provides bounded fan-out over an index range — the project's house pattern for running independent work (per-tenant maintenance, per-shard scatter-gather, WAL fsyncs) concurrently under a cap, without pulling in an errgroup dependency. Callers collect results/errors into per-index slots, mirroring the existing query/scale split fan-out.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLimit

func DefaultLimit() int

DefaultLimit is a sane concurrency cap for I/O-bound fan-out: enough to overlap backend round-trips without swamping the object store or the scheduler.

func ForEach

func ForEach(n, limit int, fn func(i int))

ForEach invokes fn(0), …, fn(n-1), running at most limit concurrently (limit ≤ 0 or ≥ n ⇒ all at once), and returns once every call has completed. Calls for distinct i run on different goroutines, so fn must not mutate shared state without its own synchronization; writing to a per-index slot (e.g. results[i], errs[i]) is the intended pattern and needs none. A worker spawns exactly min(n, limit) goroutines and distributes indices via an atomic counter.

Types

This section is empty.

Jump to

Keyboard shortcuts

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