threadpool

package
v0.0.0-...-1b41ab9 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWorkerPoolClosed = errors.New("worker pool has closed")
	ErrSendJobTimeout   = errors.New("sending job to worker pool timeout")
	ErrTaskTimeout      = errors.New("task timeout")
)

Functions

func WorkerPoolHTTPWrapper

func WorkerPoolHTTPWrapper(wp *WorkerPool, next http.Handler) http.Handler

Types

type Job

type Job interface {
	Process(ctx context.Context, out chan interface{}) error
	Callback(out interface{}, err error)
}

type JobCallback

type JobCallback func(out interface{}, err error)

type JobProcess

type JobProcess func(ctx context.Context, out chan interface{}) error

type JobWrapper

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

func NewJobWrapper

func NewJobWrapper(job Job) *JobWrapper

func NewJobWrapperFromFunc

func NewJobWrapperFromFunc(process JobProcess, callback JobCallback) *JobWrapper

func NewJobWrapperWithContext

func NewJobWrapperWithContext(ctx context.Context, job Job) *JobWrapper

func (*JobWrapper) Callback

func (jw *JobWrapper) Callback(out interface{}, err error)

func (*JobWrapper) Process

func (jw *JobWrapper) Process(ctx context.Context, out chan interface{}) error

type WorkerPool

type WorkerPool struct {
	sync.Once
	// contains filtered or unexported fields
}

func NewWorkerPool

func NewWorkerPool(n int) *WorkerPool

func (*WorkerPool) Close

func (wp *WorkerPool) Close()

func (*WorkerPool) SendJob

func (wp *WorkerPool) SendJob(ctx context.Context, job Job) error

func (*WorkerPool) Start

func (wp *WorkerPool) Start()

Jump to

Keyboard shortcuts

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