Documentation ¶
Overview ¶
* Copyright (c) 2021. App Nerds LLC. All rights reserved
* Copyright (c) 2021. App Nerds LLC. All rights reserved
* Copyright (c) 2021. App Nerds LLC. All rights reserved
* Copyright (c) 2021. App Nerds LLC. All rights reserved
* Copyright (c) 2021. App Nerds LLC. All rights reserved
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrNoAvaialableWorkers ¶
type ErrNoAvaialableWorkers struct {
Job Job
}
ErrNoAvaialableWorkers is used to describe a situation where there are no workers available to work a job
func (ErrNoAvaialableWorkers) Error ¶
func (e ErrNoAvaialableWorkers) Error() string
func (ErrNoAvaialableWorkers) GetJob ¶
func (e ErrNoAvaialableWorkers) GetJob() Job
GetJob returns the job associated with this error
type IPool ¶
type IPool interface { PutWorkerInTheQueue(worker IWorker) Shutdown() Start() QueueJob(job Job) Wait() }
IPool describes an interface for managing a pool of workers who perform jobs
type Job ¶
type Job interface {
Work(workerID int)
}
A Job is an interface structs must implement which actually executes the work to be done by a worker in the pool. The workerID is the identifier of the worker performing the job
type Pool ¶
type Pool struct { ErrorQueue chan JobError // contains filtered or unexported fields }
A Pool provides methods for managing a pool of workers who perform jobs. A pool can be configured to have a maximum number of available workers, and will wait up to a configurable amount of time for a worker to become available before returning an error
func (*Pool) PutWorkerInTheQueue ¶
PutWorkerInTheQueue puts a worker in the worker queue
type PoolConfig ¶
PoolConfig provides the ability to configure the worker pool. MaxWorkers specifies the maximum number of workers available. This essentially sets the channel size. MaxWorkerWaitTime is a duration that tells the pool how long it will wait before timing out when a client requests a worker.
type Worker ¶
A Worker is someone that performs a job. There are a finite number of workers in the pool
func (*Worker) DoJob ¶
DoJob executes the provided job. When the work is complete this worker will put itself back in the queue as available. This method execute a goroutine
func (*Worker) RejoinWorkerPool ¶
func (w *Worker) RejoinWorkerPool()
RejoinWorkerPool puts this worker back in the worker queue of the pool. A worker will rejoin the queue when she has finished the job