Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MapQueue ¶
type MapQueue[K comparable, T any] struct { // contains filtered or unexported fields }
A MapQueue is a grouping of multiple queues. Items are sent to a queue determined by the `keyFn`.
func NewMapQueue ¶
func NewMapQueue[K comparable, T any](ctx context.Context, pool Pool, keyFn func(T) K, workFn func(context.Context, T) error) *MapQueue[K, T]
NewMapQueue creates a new map queue that partitions incoming work items based on the provided `keyFn`. If the provided `ctx` is canceled, the entire set of queues will be canceled and pending work items may be lost. Additionally, the standard `errgroup` `pool` implementation will cancel the context if the `workFn` returns a non-nil error, which will also cause pending work items to be lost.
type Queue ¶
Queue is something that can enqueue a work item for asynchronous processing.
func NewSerialQueue ¶
func NewSerialQueue[T any](ctx context.Context, pool Pool, workFn func(context.Context, T) error) Queue[T]
NewSerialQueue creates a new serial queue that will handle incoming work items one by one. The single worker is stopped once the provided context is canceled. Depending on the `pool` implementation, if the `workFn` returns a non-nil error the context may be canceled. In both cases, any pending work items are lost.
type SerialQueue ¶
type SerialQueue[T any] struct { // contains filtered or unexported fields }
SerialQueue is an extremely basic Queue implementation that handles incoming work items one by one.
func (*SerialQueue[T]) Enqueue ¶
func (q *SerialQueue[T]) Enqueue(item T) bool
Add the provided `item` to the queue. Returns true if the item was added successfully.