dispatcher

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxQueue = 100
	// A buffered channel that we can send work requests on.
	JobQueue chan Job
)

Functions

This section is empty.

Types

type CommonJob

type CommonJob struct {
	Args   []interface{}
	DoFunc func(args ...interface{}) error
	Done   chan error
}

func (*CommonJob) Do

func (job *CommonJob) Do() error

type Dispatcher

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

func NewDispatcher

func NewDispatcher(maxWorkers int) *Dispatcher

func (*Dispatcher) Run

func (d *Dispatcher) Run()

type Job

type Job interface {
	Do() error
}

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