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 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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