worker

package
v1.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWaitTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PondWorkerPool

type PondWorkerPool struct {
	// contains filtered or unexported fields
}

PondWorkerPool implements a worker pool based on https://github.com/alitto/pond

func (*PondWorkerPool) Start

func (wp *PondWorkerPool) Start(parent context.Context) (context.Context, error)

func (*PondWorkerPool) Submit

func (wp *PondWorkerPool) Submit(workFunc func() error)

func (*PondWorkerPool) WaitForComplete

func (wp *PondWorkerPool) WaitForComplete() error

type WorkerPool

type WorkerPool interface {
	// Submit sends a work item to the worker pool to be processed.
	Submit(workFunc func() error)

	// Start starts the worker pool and returns a derived context which is canceled the first time
	// a function submitted to the group returns a non-nil error or the first time Wait returns,
	// whichever occurs first.
	Start(parent context.Context) (context.Context, error)

	// WaitForComplete blocks until either all the tasks submitted to this group have completed,
	// one of them returned a non-nil error or the context associated to this group was canceled.
	WaitForComplete() error
}

WorkerPool provides a worker pool for parallelised processing tasks.

func PoolFactory

func PoolFactory(size int, capacity int) (WorkerPool, error)

PoolFactory creates a new worker pool instance from the provided config.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL