workqueue

package
v0.0.0-...-8964234 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 6 Imported by: 0

README

work queue

base CSP

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWorkQueueStopped = errors.New("work-queue has stopped")
	ErrEnqueueTimeout   = errors.New("enqueue timeout")
)

Functions

func StackRecord

func StackRecord() string

Types

type Option

type Option func(*WorkQueue)

func WithEnqueueTimeout

func WithEnqueueTimeout(t time.Duration) Option

func WithHandler

func WithHandler(h func(msg interface{})) Option

func WithMaxIdleWorker

func WithMaxIdleWorker(num int) Option

func WithMaxWorker

func WithMaxWorker(member int) Option

func WithQueueName

func WithQueueName(name string) Option

func WithQueueSize

func WithQueueSize(num int) Option

func WithWatchPeriod

func WithWatchPeriod(t time.Duration) Option

func WithWorkerMaxWaiting

func WithWorkerMaxWaiting(duration time.Duration) Option

type WorkQueue

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

func NewQueue

func NewQueue(name string, timeout time.Duration, queueSize, workSize int,
	handler func(msg interface{})) *WorkQueue

func NewQueueWithOptions

func NewQueueWithOptions(opts ...Option) *WorkQueue

func NewQueueWithWatch

func NewQueueWithWatch(name string, timeout, watch time.Duration,
	queueSize, workSize int, handler func(msg interface{})) *WorkQueue

func (*WorkQueue) Enqueue

func (wq *WorkQueue) Enqueue(msg interface{}) error

func (*WorkQueue) EnqueueWithTimeout

func (wq *WorkQueue) EnqueueWithTimeout(msg interface{}, timeout time.Duration) error

func (*WorkQueue) Stop

func (wq *WorkQueue) Stop()

type Worker

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

func NewWorker

func NewWorker(id int, wq *WorkQueue) *Worker

Jump to

Keyboard shortcuts

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