worker

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WorkQueue = make(chan WorkRequest, 100)
View Source
var WorkerQueue chan chan WorkRequest

Functions

func Notify

func Notify(subject string, text string, outfilename string)

func RunScript

func RunScript(work *WorkRequest) (string, error)

func StartDispatcher

func StartDispatcher(nworkers int)

Types

type WorkRequest

type WorkRequest struct {
	Name   string
	Action string
	Args   []string
}

type Worker

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

func NewWorker

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

NewWorker creates, and returns a new Worker object. Its only argument is a channel that the worker can add itself to whenever it is done its work.

func (Worker) Start

func (w Worker) Start()

This function "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