worker

package
v0.0.0-...-d5e3614 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Idle    int32 = iota
	Active        = 1
	Closing       = 2
	Closed        = 3
)

Variables

View Source
var (
	DefaultPool = NewWorkerPool(context.Background(), 0, 0)
)

Functions

This section is empty.

Types

type Worker

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

Maintains a cached goroutine that can process one job at a time and is returned back to a sync.Pool

type WorkerJob

type WorkerJob interface {
	Run()
}

type WorkerPool

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

func NewWorkerPool

func NewWorkerPool(ctx context.Context, min, max int) *WorkerPool

func (*WorkerPool) Dispatch

func (w *WorkerPool) Dispatch(job WorkerJob) bool

func (*WorkerPool) Get

func (w *WorkerPool) Get() *Worker

func (*WorkerPool) Name

func (w *WorkerPool) Name() string

func (*WorkerPool) PrintStats

func (w *WorkerPool) PrintStats()

func (*WorkerPool) Put

func (w *WorkerPool) Put(worker *Worker)

func (*WorkerPool) Register

func (w *WorkerPool) Register(registry metrics.Registry)

func (*WorkerPool) Stop

func (w *WorkerPool) Stop()

Jump to

Keyboard shortcuts

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