batch

package
v1.19.34-clash.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: GPL-3.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch[T any] struct {
	// contains filtered or unexported fields
}

Batch similar to errgroup, but can control the maximum number of concurrent

func New

func New[T any](ctx context.Context, opts ...Option[T]) (*Batch[T], context.Context)

func (*Batch[T]) Go

func (b *Batch[T]) Go(key string, fn func() (T, error))

func (*Batch[T]) Result

func (b *Batch[T]) Result() map[string]Result[T]

func (*Batch[T]) Wait

func (b *Batch[T]) Wait() *Error

func (*Batch[T]) WaitAndGetResult

func (b *Batch[T]) WaitAndGetResult() (map[string]Result[T], *Error)

type Error

type Error struct {
	Key string
	Err error
}

type Option

type Option[T any] func(b *Batch[T])

func WithConcurrencyNum

func WithConcurrencyNum[T any](n int) Option[T]

type Result

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

Jump to

Keyboard shortcuts

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