simultaneously

package
v0.0.0-...-d789bda Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPanicRecovered = errors.New("panic recovered")

ErrPanicRecovered is the base error for panic recovery.

Functions

func Do

func Do(maxConcurrent int, f ...Job) error

Do runs the given functions in parallel and returns the first error encountered. See SimultaneouslyCtx for more information.

func DoCtx

func DoCtx(ctx context.Context, maxConcurrent int, callback ...Job) error

DoCtx runs the given functions in parallel and returns the first error encountered. If no error is encountered, it returns nil. In the event that an error happens, all other functions are canceled (via their context) to hopefully save on CPU cycles. It's up to the individual functions to check their context and return early if they are canceled.

The maxConcurrent parameter is used to limit the number of functions that run at the same time. If maxConcurrent is less than 1, all functions will run at the same time.

Panics that occur within the callback functions are automatically recovered and converted to errors. This prevents a single panicking function from crashing the entire process.

Types

type Job

type Job func(ctx context.Context) error

Job is a function that performs a unit of work and returns an error if it fails.

Jump to

Keyboard shortcuts

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