work_queue

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxWorker = runtime.NumCPU()
	MaxQueue  = 100
)
View Source
var JobQueue chan Job

A buffered channel that we can send work requests on.

Functions

func Sample

func Sample()

func WorkTest

func WorkTest(params IJobParams) error

Types

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 IJobParams

type IJobParams interface {
	AddString(string, string)
	String(string) string
}

type Job

type Job struct {
	Payload func(IJobParams) error
	Data    *JobParams
}

Job represents the job to be run

type JobParams

type JobParams struct {
	// contains filtered or unexported fields
}

func (*JobParams) AddString

func (j *JobParams) AddString(k string, v string)

func (*JobParams) String

func (j *JobParams) String(k string) string

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