worker

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 8 Imported by: 1

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 DoWithCtx added in v0.24.0

type DoWithCtx func(ctx context.Context) error

type ErrorHandler

type ErrorHandler func(error)

ErrorHandler 错误处理方法

type IWorker added in v0.5.0

type IWorker interface {
	Push(job Job) error
	Start()
	Stop()
}

type IWorkerMock added in v0.5.0

type IWorkerMock interface {
	Push(job Job) error
	Start()
	Stop()
}

type Job

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

Job 工作

func NewJob added in v0.24.0

func NewJob(do DoWithCtx, timeout time.Duration, eh ErrorHandler) *Job

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 停止

type WorkerMock added in v0.5.0

type WorkerMock struct {
	PushFunc func(job Job) error

	StartFunc func()

	StopFunc func()
}

func (*WorkerMock) Push added in v0.5.0

func (mockRecv *WorkerMock) Push(job Job) error

func (*WorkerMock) Start added in v0.5.0

func (mockRecv *WorkerMock) Start()

func (*WorkerMock) Stop added in v0.5.0

func (mockRecv *WorkerMock) Stop()

type WorkerMockMock added in v0.5.0

type WorkerMockMock struct {
	PushFunc func(job Job) error

	StartFunc func()

	StopFunc func()
}

func (*WorkerMockMock) Push added in v0.5.0

func (mockRecv *WorkerMockMock) Push(job Job) error

func (*WorkerMockMock) Start added in v0.5.0

func (mockRecv *WorkerMockMock) Start()

func (*WorkerMockMock) Stop added in v0.5.0

func (mockRecv *WorkerMockMock) Stop()

Jump to

Keyboard shortcuts

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