workerpool

package
v0.0.0-...-346acf3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobProcessor

type JobProcessor[TJob any] interface {
	Process(
		ctx context.Context,
		job TJob) error
}

JobProcessor defines the contract for processing a single job within a workflow.

type Pool

type Pool[TJob any] struct{}

Generic pool type, can work with any job type.

func (Pool[TJob]) Start

func (p Pool[TJob]) Start(ctx context.Context, numWorkers int, processor JobProcessor[TJob], jobs []TJob) []error

func (Pool[TJob]) StartWorker

func (p Pool[TJob]) StartWorker(
	ctx context.Context,
	processor JobProcessor[TJob],
	id int,
	wg *sync.WaitGroup,
	jobs <-chan TJob,
	errChan chan<- error)

Jump to

Keyboard shortcuts

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