errgroup

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ForIndexGroup added in v0.0.3

type ForIndexGroup struct {
	// contains filtered or unexported fields
}

ForIndexGroup 是一个引用for index执行多个携程的ErrGroup

func WithCancelForIndexGroup added in v0.0.3

func WithCancelForIndexGroup(ctx context.Context) *ForIndexGroup

WithCancelForIndexGroup 创建ForIndexGroup带Context和Cancel

func WithContextForIndexGroup added in v0.0.3

func WithContextForIndexGroup(ctx context.Context) *ForIndexGroup

WithContextForIndexGroup 创建ForIndexGroup带Group

func (*ForIndexGroup) Go added in v0.0.3

func (g *ForIndexGroup) Go(f func(ctx context.Context, i int) error, i int)

Go 启动携程

func (*ForIndexGroup) Wait added in v0.0.3

func (g *ForIndexGroup) Wait() error

Wait 阻塞得到结果

type Group

type Group struct {
	// contains filtered or unexported fields
}

A Group is a collection of goroutines working on subtasks that are part of the same overall task.

A zero Group is valid and does not cancel on error.

func WithCancel

func WithCancel(ctx context.Context) *Group

WithCancel create a new Group and an associated Context derived from ctx.

given function from Go will receive context derived from this ctx, The derived Context is canceled the first time a function passed to Go returns a non-nil error or the first time Wait returns, whichever occurs first.

func WithContext

func WithContext(ctx context.Context) *Group

WithContext create a Group. given function from Go will receive this context,

func (*Group) GOMAXPROCS

func (g *Group) GOMAXPROCS(n int)

GOMAXPROCS set max goroutine to work.

func (*Group) Go

func (g *Group) Go(f func(ctx context.Context) error)

Go calls the given function in a new goroutine.

The first call to return a non-nil error cancels the group; its error will be returned by Wait.

func (*Group) Wait

func (g *Group) Wait() error

Wait blocks until all function calls from the Go method have returned, then returns the first non-nil error (if any) from them.

Jump to

Keyboard shortcuts

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