Version: v1.3.1 Latest Latest

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

Go to latest
Published: Mar 12, 2021 License: Apache-2.0 Imports: 3 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Dispatcher

type Dispatcher interface {
	Dispatch(task Task)

type DispatcherImpl

type DispatcherImpl struct {

	// A pool of workers channels that are registered with the dispatcher
	WorkerPool chan chan Task
	// contains filtered or unexported fields

func NewDispatcher

func NewDispatcher(maxWorkers int, targetQueue chan Task) *DispatcherImpl

func (*DispatcherImpl) Dispatch

func (d *DispatcherImpl) Dispatch(job Task)

func (*DispatcherImpl) Run

func (d *DispatcherImpl) Run() error

func (*DispatcherImpl) Stop

func (d *DispatcherImpl) Stop() error

type Task

type Task interface {
	Perform() error

Job represents the job to be run

type Worker

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

Worker represents the worker that executes the job

func NewWorker

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