parallel

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 3 Imported by: 0

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.

Types

type Result

type Result[T any] struct {
	Value T
	Err   error
}

Result holds the result of a parallel operation.

Jump to

Keyboard shortcuts

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