jobqueue

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Launch

func Launch[J, R any](
	ctx context.Context,
	workersCount int,
	queueSize int,
	f DoFunc[J, R],
) (
	jobQueue chan *J,
	resultsChan chan JobResult[J, R],
	cleanup func(),
)

Launch launches arbitrary number of worker goroutines and which receive jobs from the job queue and sends the result to results channel.

Types

type DoFunc

type DoFunc[J, R any] func(ctx context.Context, job *J) (*R, error)

DoFunc is a function type that defines the job processing function.

type JobResult

type JobResult[J, R any] struct {
	Job    *J
	Result *R
	Err    error
}

JobResult represents the result of a job processed by a worker. It contains the job, the result of the job, and any error that occurred during processing.

Jump to

Keyboard shortcuts

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