Documentation ¶
Index ¶
Constants ¶
View Source
const ( DispatcherStatusStopped = iota DispatcherStatusRunning )
Different status values for the dispatcher
Variables ¶
View Source
var ( // ErrJobQueueFull happens when jobs queue reaches its maximum size and a new job // needs to be attended ErrJobQueueFull = errors.New("Jobs queue is full") // ErrJobQueueClosed happens when job queue gets closed and a new job arrives ErrJobQueueClosed = errors.New("Jobs queue already closed") )
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct { Queue *JobChannel // contains filtered or unexported fields }
Dispatcher is the pool engine. Holds the queue receiving the jobs to be processed and holds the queue of available workers. When a job is received, takes the next available worker job channel and sends the job to it. Then that channel is read and processed by the corresponding worker
func NewDispatcher ¶
func NewDispatcher(queueSize, poolSize int) *Dispatcher
NewDispatcher returns a new dispatcher with a new workers pool of the requested size
func (*Dispatcher) Start ¶
func (d *Dispatcher) Start()
Start creates and starts all the workers until filling the pool
type DispatcherStatus ¶
type DispatcherStatus int
DispatcherStatus type representing the current status of the dispatcher
type JobChannel ¶
type JobChannel struct {
// contains filtered or unexported fields
}
JobChannel a channel to read or write jobs
Click to show internal directories.
Click to hide internal directories.