tasklet

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunConcurrent added in v0.6.1

func RunConcurrent(ctx context.Context, sem Semaphore, tasks []Tasklet) error

RunConcurrent runs every task in its own goroutine, acquiring one slot per task before spawning it, so no more than sem's capacity is in flight. The first error cancels the context handed to the remaining tasks; the first error raised is the one returned. A failed acquire stops scheduling but never abandons tasks already in flight.

func RunConcurrentLimit added in v0.6.1

func RunConcurrentLimit(ctx context.Context, limit int, tasks []Tasklet) error

RunConcurrentLimit is RunConcurrent with a budget no other call shares: it mints a semaphore of capacity limit for this call alone. A non-positive limit runs unbounded, matching errgroup's SetLimit.

Types

type Semaphore added in v0.6.1

type Semaphore interface {
	Acquire(ctx context.Context, n int64) error
	Release(n int64)
}

Semaphore bounds how many tasks RunConcurrent keeps in flight. *semaphore.Weighted satisfies it as-is.

type Tasklet

type Tasklet interface {
	// Execute the task, can take long time
	Execute(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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