worker

package
v0.0.49 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package worker provides worker processes

Package worker provides worker processes

Package worker provides worker processes

Package worker provides worker processes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobFunc

type JobFunc func(context.Context) error

type Queue

type Queue interface {
	Start(ctx context.Context) (<-chan error, error)
	Push(ctx context.Context, job JobFunc) error
	Pop(ctx context.Context) (JobFunc, error)
	Len() uint64
}

func NewQueue

func NewQueue(opts ...QueueOption) (Queue, error)

type QueueOption

type QueueOption func(q *queue) error

func WithQueueBuffer

func WithQueueBuffer(buffer int) QueueOption

func WithQueueCheckDuration added in v0.0.30

func WithQueueCheckDuration(dur string) QueueOption

func WithQueueErrGroup

func WithQueueErrGroup(eg errgroup.Group) QueueOption

type Worker

type Worker interface {
	Start(ctx context.Context) (<-chan error, error)
	Pause()
	Resume()
	IsRunning() bool
	Name() string
	Len() uint64
	TotalRequested() uint64
	TotalCompleted() uint64
	Dispatch(ctx context.Context, f JobFunc) error
}

func New

func New(opts ...WorkerOption) (Worker, error)

type WorkerOption

type WorkerOption func(w *worker) error

func WithErrGroup

func WithErrGroup(eg errgroup.Group) WorkerOption

func WithLimitation

func WithLimitation(limit int) WorkerOption

func WithName

func WithName(name string) WorkerOption

func WithQueueOption added in v0.0.30

func WithQueueOption(opts ...QueueOption) WorkerOption

Jump to

Keyboard shortcuts

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