Documentation
¶
Overview ¶
Package parallel provides utilities for parallel execution of operations.
Index ¶
Constants ¶
View Source
const DefaultLimit = 10
DefaultLimit is the default concurrency limit for parallel operations.
Variables ¶
This section is empty.
Functions ¶
func ExecuteMap ¶
func ExecuteMap[K comparable, V any, R any]( ctx context.Context, entries map[K]V, fn func(ctx context.Context, key K, value V) (R, error), ) map[K]*Result[R]
ExecuteMap runs fn for each key-value pair in entries concurrently. Results are collected in a map keyed by the same keys as entries. Individual errors are captured in Result.Err rather than failing the entire operation.
func ExecuteMapWithLimit ¶
func ExecuteMapWithLimit[K comparable, V any, R any]( ctx context.Context, entries map[K]V, limit int, fn func(ctx context.Context, key K, value V) (R, error), ) map[K]*Result[R]
ExecuteMapWithLimit is like ExecuteMap but with a custom concurrency limit. A non-positive limit falls back to DefaultLimit: errgroup.SetLimit(0) uses a zero-capacity semaphore that would block the first g.Go forever (a deadlock), so it is never passed through.
Types ¶
Click to show internal directories.
Click to hide internal directories.