worker

package
v0.0.0-...-115e584 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWorkerPoolFull = errors.New("Job queue is full now, this Job will be droped")

Functions

This section is empty.

Types

type Job

type Job func()

type Option

type Option func(*options)

Option 可选参数

func WithDropQueue

func WithDropQueue(drop bool) Option

func WithMaxQueueSize

func WithMaxQueueSize(num int) Option

func WithMaxWorkersCount

func WithMaxWorkersCount(num int) Option

type WorkerPool

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

WorkerPool 协程池实现

func New

func New(opts ...Option) *WorkerPool

New 根据选项新建一个协程池

func (*WorkerPool) Release

func (wp *WorkerPool) Release()

func (*WorkerPool) Run

func (wp *WorkerPool) Run(job Job) error

Run 通过协程池执行带处理任务 如果工作池满,返回ErrWorkerPoolFull错误,f将被丢弃,业务方可自行判断是否进行等待重试

Jump to

Keyboard shortcuts

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