worker

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WorkQueue = make(chan Work, 100)

WorkQueue is the global queue of work to dispatch

View Source
var WorkerQueue chan chan Work

WorkerQueue is the global queue of Workers

Functions

func StartDispatcher

func StartDispatcher(nworkers int)

StartDispatcher is charged to start n workers.

Types

type ChanWriter

type ChanWriter struct {
	ByteChan chan []byte
}

ChanWriter is a simple writer to a channel of byte.

func (*ChanWriter) Write

func (c *ChanWriter) Write(p []byte) (int, error)

type Work added in v1.15.0

type Work interface {
	ID() uint64
	Name() string
	Run() error
	Close()
	SendMessage(message string)
	Logs(filter string) string
	StatusLabel() string
	Err() error
}

type Worker

type Worker struct {
	ID          int
	Work        chan Work
	WorkerQueue chan chan Work
	QuitChan    chan bool
}

Worker is a go routine in charge of executing a work.

func NewWorker

func NewWorker(id int, workerQueue chan chan Work) Worker

NewWorker creates, and returns a new Worker object.

func (Worker) Start

func (w Worker) Start()

Start is the function to starts the worker by starting a goroutine. That is an infinite "for-select" loop.

func (Worker) Stop

func (w Worker) Stop()

Stop tells the worker to stop listening for work requests. Note that the worker will only stop *after* it has finished its work.

Jump to

Keyboard shortcuts

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