batch

package
v1.18.8 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

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