WorkQueue

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRetryTimeout = 60 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type DispatcherConfig

type DispatcherConfig struct {
	JobsTopic string
}

type IQueuedWorker

type IQueuedWorker interface {
	Start()
	DoWork(Work)
}

type IndexJobPool

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

func NewJobPool

func NewJobPool() *IndexJobPool

func (*IndexJobPool) EnqueueJob

func (j *IndexJobPool) EnqueueJob(work Work)

func (*IndexJobPool) GetNewJob

func (j *IndexJobPool) GetNewJob() Work

type JobDispatcher

type JobDispatcher struct {
	EmptyQueueChan chan bool // channel to communicate that queue was consumed
	// contains filtered or unexported fields
}

func NewJobDispatcher

func NewJobDispatcher() JobDispatcher

func (JobDispatcher) BuildWorkers

func (j JobDispatcher) BuildWorkers(count int, constructor WorkerConstructor)

func (JobDispatcher) EnqueueWork added in v0.1.1

func (j JobDispatcher) EnqueueWork(w Work)

func (JobDispatcher) SetRetryTimeout added in v0.1.2

func (j JobDispatcher) SetRetryTimeout(timeout time.Duration)

func (JobDispatcher) Start

func (j JobDispatcher) Start()

TODO listen for incoming jobs on JobsTopic

type PoolConfig

type PoolConfig struct {
	StartHeight int64
	EndHeight   int64
}

type QueuedWorker

type QueuedWorker struct {
	Worker IQueuedWorker
}

type Work

type Work struct {
	JobId  int64
	Params interface{}
}

type WorkQueue

type WorkQueue struct {
	ID          string
	WorkersChan chan chan Work // used to communicate between dispatcher and workers
	JobsChan    chan Work
	End         chan bool
}

func (WorkQueue) ListenForJobs

func (w WorkQueue) ListenForJobs(cb func(Work))

type WorkerConstructor

type WorkerConstructor func(string, chan chan Work) QueuedWorker

Jump to

Keyboard shortcuts

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