pool

package
v0.0.71 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package pool contains a generic implementation of the worker pool pattern for concurrent processing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	// Description text description for this job to use in log messages
	Description string
	// Run function that performs work
	Run func() error
}

type Option

type Option func(*Options)

Option function for configuring Options

type Options

type Options struct {
	// NumWorkers number of jobs to execute concurrently
	NumWorkers int
	// StopProcessingOnError whether to stop processing work items in the event a job returns an error
	StopProcessingOnError bool
}

type Pool

type Pool interface {
	// Execute starts execution of the pool, returning an error that aggregates errors from all jobs (if any were encountered)
	Execute() error
	// NumWorkers returns the number of workers in the pool
	NumWorkers() int
}

Pool implements the worker pool pattern for concurrent processing

func New

func New(jobs []Job, options ...Option) Pool

Jump to

Keyboard shortcuts

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