worker

package
v1.2.17 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 2 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 {
	// JobQueue A buffered channel that we can send work requests on.
	JobQueue chan Job
	// A pool of workers channels that are registered with the dispatcher
	WorkerPool chan chan Job
	// Len represents num of worker
	Len int
}

Dispatcher -> Processing Data

func NewDispatcher

func NewDispatcher(maxWorkers int) *Dispatcher

NewDispatcher represents Processing Data

func (*Dispatcher) AddJob

func (d *Dispatcher) AddJob(j Job)

AddJob represents Generate Data

func (*Dispatcher) Run

func (d *Dispatcher) Run()

Run starting n number of workers

type Job

type Job interface {
	Do() (err error)
}

Job defined

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

NewWorker represents the 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