worker

package
v0.0.0-...-bb1a4e7 Latest Latest
Warning

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

Go to latest
Published: May 9, 2020 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JobQueue chan JobInterface

A buffered channel that we can send work requests on.

Functions

func SubmitJob

func SubmitJob(job JobInterface)

Types

type Dispatcher

type Dispatcher struct {
	// A pool of workers channels that are registered with the dispatcher
	WorkerPool chan chan JobInterface
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher(maxWorkers int) *Dispatcher

func (*Dispatcher) Run

func (d *Dispatcher) Run()

type GoroutineResponse

type GoroutineResponse struct {
	Err  error
	Data []byte
}

type Job

type Job struct {
	JobInterface
	Payload []byte
}

Job represents the job to be run

func (*Job) Run

func (j *Job) Run() error

type JobInterface

type JobInterface interface {
	Run() error
}

type Worker

type Worker struct {
	WorkerPool chan chan JobInterface
	JobChannel chan JobInterface
	// contains filtered or unexported fields
}

Worker represents the worker that executes the job

func NewWorker

func NewWorker(workerPool chan chan JobInterface) Worker

func (Worker) Start

func (w Worker) Start()

Start method starts the run loop for the worker, listening for a quit channel in case we need to stop it

func (Worker) Stop

func (w Worker) Stop()

Stop signals the worker to stop listening for work requests.

Jump to

Keyboard shortcuts

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