Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParallelChunkMap ¶ added in v0.58.2
func ParallelChunkMap[T any, R any]( ctx context.Context, items []T, workerFunc func(ctx context.Context, workerIdx int, chunk []T, onProcessed func(int)) (R, error), onProgress ProgressCallback, opts ProgressOptions, ) ([]R, error)
ParallelChunkMap partitions the given slice into chunks across worker goroutines, executes workerFunc concurrently with errorgroup, and periodically reports progress.
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool enables running a goroutine with max parallel count limit.
type ProgressCallback ¶ added in v0.58.2
ProgressCallback receives streaming progress percentage (in [0.0, 1.0] or a mapped range) and a message.
type ProgressOptions ¶ added in v0.58.2
type ProgressOptions struct {
// Interval is the interval between periodic progress updates. Defaults to 1s if <= 0.
Interval time.Duration
// MessageFmt is the template for progress messages (e.g. "Processing (%d/%d)...").
MessageFmt string
// MinProgress is the starting progress percentage for this step (e.g. 0.0).
MinProgress float64
// MaxProgress is the ending progress percentage for this step (e.g. 1.0).
MaxProgress float64
// NumWorkers overrides the number of parallel workers. Defaults to GOMAXPROCS if <= 0.
NumWorkers int
}
ProgressOptions defines configuration for progress reporting in parallel operations.
Click to show internal directories.
Click to hide internal directories.