Documentation ¶
Overview ¶
Package errgroup provides synchronization, error propagation, and Context cancelation for groups of goroutines working on subtasks of a common task. This provide a concurrent call util and it's safe than golang.org/x/sync/errgroup ones
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnyMutex ¶
func NewAnyMutex ¶
func NewAnyMutex(any interface{}) *AnyMutex
type AtomicBool ¶
type AtomicBool struct {
// contains filtered or unexported fields
}
AtomicBool is an atomic Boolean.
func NewAtomicBool ¶
func NewAtomicBool(initial bool) *AtomicBool
NewAtomicBool creates a AtomicBool.
func (*AtomicBool) CAS ¶
func (b *AtomicBool) CAS(old, new bool) bool
CAS is an atomic compare-and-swap.
func (*AtomicBool) Store ¶
func (b *AtomicBool) Store(new bool)
Store atomically stores the passed value.
func (*AtomicBool) Swap ¶
func (b *AtomicBool) Swap(new bool) bool
Swap sets the given value and returns the previous value.
func (*AtomicBool) Toggle ¶
func (b *AtomicBool) Toggle() bool
Toggle atomically negates the Boolean and returns the previous value.
type AtomicString ¶
type AtomicString struct {
// contains filtered or unexported fields
}
func NewAtomicString ¶
func NewAtomicString(str string) *AtomicString
func (*AtomicString) Load ¶
func (s *AtomicString) Load() string
func (*AtomicString) Store ¶
func (s *AtomicString) Store(str string)
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 WithContext ¶
WithContext returns a new Group and an associated Context derived from 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.
type Weighted ¶
type Weighted struct {
// contains filtered or unexported fields
}
Weighted provides a way to bound concurrent access to a resource. The callers can request access with a given weight.
func NewWeighted ¶
NewWeighted creates a new weighted semaphore with the given maximum combined weight for concurrent access.
func (*Weighted) Acquire ¶
Acquire acquires the semaphore with a weight of n, blocking until resources are available or ctx is done. On success, returns nil. On failure, returns ctx.Err() and leaves the semaphore unchanged.
If ctx is already done, Acquire may still succeed without blocking.
func (*Weighted) TryAcquire ¶
TryAcquire acquires the semaphore with a weight of n without blocking. On success, returns true. On failure, returns false and leaves the semaphore unchanged.