batch

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: GPL-2.0 Imports: 4 Imported by: 26

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
}

func (*Error) Error added in v0.2.3

func (e *Error) Error() string

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