Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcurrentQueue ¶
type ConcurrentQueue struct {
// contains filtered or unexported fields
}
ConcurrentQueue is a type that can be used to queue up functions to be run concurrently. It handles concurrency and error tracking internally, so that the caller doesn't have to worry about it. The queue will stop processing functions after the first error it encounters.
func NewConcurrentQueue ¶
func NewConcurrentQueue(opts ...QueueOption) *ConcurrentQueue
NewConcurrentQueue returns a new ConcurrentQueue with the given concurrency.
func (*ConcurrentQueue) Push ¶
func (c *ConcurrentQueue) Push(f QueueFunc)
Push adds a function to the queue. If a function before it errors, then the the error for the given function will be lost.
func (*ConcurrentQueue) Wait ¶
func (c *ConcurrentQueue) Wait() error
Wait blocks until all functions finish and returns the first error that occurred. If no errors occurred, then nil is returned. The queue can no longer be used after Wait is called. If no functions are pushed to the queue, then nil is returned. If functions are added to the queue after Wait is called, there is no guarantee that they will be executed.
type QueueFunc ¶
type QueueFunc func() error
QueueFunc is a function that takes no arguments and returns an error.
type QueueOption ¶
type QueueOption func(*queueConfig)
QueueOption is a function that configures a queue.
func WithLogger ¶
func WithLogger(logger *log.Logger, verbosity int) QueueOption
func WithMaxConcurrency ¶
func WithMaxConcurrency(concurrency int) QueueOption