worker

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWorkerIsStop = errors.New("Worker is stop")
	ErrNilJobDo     = errors.New("Job do field is nil")
)

错误

View Source
var DefaultWorker = New(defaultCount)

DefaultWorker 默认Wroker

Functions

This section is empty.

Types

type Do

type Do func() error

Do 执行

type ErrorHandler

type ErrorHandler func(error)

ErrorHandler 错误处理方法

type Job

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

Job 工作

func MakeJob

func MakeJob(do Do, timeout time.Duration, eh ErrorHandler) Job

MakeJob 新建工作

type Worker

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

Worker 工人

func New

func New(n int) *Worker

New 新建

func (*Worker) Push

func (w *Worker) Push(job Job) error

Push 添加

func (*Worker) Start

func (w *Worker) Start()

Start 开始

func (*Worker) Stop

func (w *Worker) Stop()

Stop 停止

Jump to

Keyboard shortcuts

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