worker

package
v0.0.0-...-e168591 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2017 License: MIT, MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher struct {
	MaxWorkers int
	// A pool of workers channels that are registered with the dispatcher
	WorkerPool chan chan Job
	Workers    []Worker
}

func NewDispatcher

func NewDispatcher(maxWorkers int) *Dispatcher

func (*Dispatcher) Run

func (d *Dispatcher) Run(queues int) chan Job

func (*Dispatcher) Stop

func (d *Dispatcher) Stop()

type Job

type Job interface {
	String() string
	Process() error
	Result(error)
}

Job interface

type Worker

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

Worker represents the worker that executes the job

func NewWorker

func NewWorker(workerPool chan chan Job) 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