jobtracker

package module
v0.0.0-...-eb31a90 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: MIT Imports: 5 Imported by: 1

README

jobtracker - a self terminating concurrent job queue for indeterminate workloads in golang

This library is primarily useful for technically-recursive work with an unknown size at the start of the work. It was originally created for goop where i had a need for a concurrent job queue where jobs have the ability to queue new jobs, which terminates itself once all work is done (only indicated by the lack of new jobs).

Installation

go get -u github.com/deletescape/jobtracker@latest

Examples

You can find some examples in the _examples/ directory.

Projects using jobtracker

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultNapper

func DefaultNapper(naps int32, activeWorkers int32)

DefaultNapper will sleep a minimum of 15 milliseconds per nap, but increasingly longer the more often workers go idle this ensures that idle workers do not take up too much cpu time, and should prevent accidental early exits

Types

type Context

type Context interface{}

type JobTracker

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

func NewJobTracker

func NewJobTracker(worker Worker, maxConcurrency int32, napper Napper) *JobTracker

func (*JobTracker) AddJob

func (jt *JobTracker) AddJob(job string)

func (*JobTracker) AddJobs

func (jt *JobTracker) AddJobs(jobs ...string)

func (*JobTracker) StartAndWait

func (jt *JobTracker) StartAndWait(context Context, forceMaxConcurrency bool)

type Napper

type Napper func(naps, activeWorkers int32)

type Worker

type Worker func(jt *JobTracker, job string, context Context)

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL