Documentation
¶
Index ¶
- func Bulk[T any](ctx context.Context, ch <-chan T, count int, ...) <-chan []T
- func CopyFirst[T any](ctx context.Context, input <-chan T) (first T, forward <-chan T, err error)
- func ErrgroupReceive(g *errgroup.Group, err <-chan error)
- func WaitAsync(w Waiter) <-chan error
- type BulkChunkSplitPolicy
- type BulkChunkSplitPolicyFactory
- type Bulker
- type Cond
- type Counter
- type Waiter
- type WaiterFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bulk ¶
func Bulk[T any]( ctx context.Context, ch <-chan T, count int, splitPolicyFactory BulkChunkSplitPolicyFactory[T], ) <-chan []T
Bulk reads all values from a channel and streams them in chunks into a returned channel.
func CopyFirst ¶
func CopyFirst[T any]( ctx context.Context, input <-chan T, ) (first T, forward <-chan T, err error)
CopyFirst asynchronously forwards all items from input to forward and synchronously returns the first item.
func ErrgroupReceive ¶
ErrgroupReceive adds a goroutine to the specified group that returns the first non-nil error (if any) from the specified channel. If the channel is closed, it will return nil.
Types ¶
type BulkChunkSplitPolicy ¶
BulkChunkSplitPolicy is a state machine which tracks the items of a chunk a bulker assembles. A call takes an item for the current chunk into account. Output true indicates that the state machine was reset first and the bulker shall finish the current chunk now (not e.g. once $size is reached) without the given item.
func NeverSplit ¶
func NeverSplit[T any]() BulkChunkSplitPolicy[T]
NeverSplit returns a pseudo state machine which never demands splitting.
type BulkChunkSplitPolicyFactory ¶
type BulkChunkSplitPolicyFactory[T any] func() BulkChunkSplitPolicy[T]
type Bulker ¶
type Bulker[T any] struct { // contains filtered or unexported fields }
Bulker reads all values from a channel and streams them in chunks into a Bulk channel.
type Cond ¶
type Cond struct {
// contains filtered or unexported fields
}
Cond implements a channel-based synchronization for goroutines that wait for signals or send them. Internally based on a controller loop that handles the synchronization of new listeners and signal propagation, which is only started when NewCond is called. Thus the zero value cannot be used.
func (*Cond) Broadcast ¶
func (c *Cond) Broadcast()
Broadcast sends a signal to all current listeners by closing the previously returned channel from Wait. Panics if the controller loop has already ended.
func (*Cond) Close ¶
Close stops the controller loop, waits for it to finish, and returns a nil error. Implements the io.Closer interface, hence that return type is required.
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter implements an atomic counter.
type Waiter ¶
type Waiter interface {
Wait() error // Wait waits for execution to complete.
}
Waiter implements the Wait method, which blocks until execution is complete.
type WaiterFunc ¶
type WaiterFunc func() error
The WaiterFunc type is an adapter to allow the use of ordinary functions as Waiter. If f is a function with the appropriate signature, WaiterFunc(f) is a Waiter that calls f.