Documentation ¶
Index ¶
- func Bulk[T any](ctx context.Context, ch <-chan T, count int, ...) <-chan []T
- func CopyFirst(ctx context.Context, input <-chan contracts.Entity) (first contracts.Entity, forward <-chan contracts.Entity, err error)
- func ErrgroupReceive(g *errgroup.Group, err <-chan error)
- func WaitAsync(w contracts.Waiter) <-chan error
- type Atomic
- type BulkChunkSplitPolicy
- type BulkChunkSplitPolicyFactory
- type Bulker
- type Cond
- type Counter
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( ctx context.Context, input <-chan contracts.Entity, ) (first contracts.Entity, forward <-chan contracts.Entity, 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 Atomic ¶
type Atomic[T any] struct { // contains filtered or unexported fields }
Atomic is a type-safe wrapper around atomic.Value.
func (*Atomic[T]) CompareAndSwap ¶
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.
func SplitOnDupId ¶
func SplitOnDupId[T contracts.IDer]() BulkChunkSplitPolicy[T]
SplitOnDupId returns a state machine which tracks the inputs' IDs. Once an already seen input arrives, it 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 an error if any. Implements the io.Closer interface.