Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct { WorkerPool chan chan interface{} MaxWorkers int Processor WorkProcessor Workers []Worker // contains filtered or unexported fields }
Dispatcher holds the worker pool and delegates jobs to those workers
func NewDispatcher ¶
func NewDispatcher(processor WorkProcessor) *Dispatcher
NewDispatcher creates a new dispatcher with respective processor
func (*Dispatcher) Queue ¶
func (d *Dispatcher) Queue(job interface{})
Queue sends a job to be processed
func (*Dispatcher) QueueAfter ¶
func (d *Dispatcher) QueueAfter(job interface{}, t time.Duration)
QueueAfter sends a job to be processed after x amount of time
func (*Dispatcher) Run ¶
func (d *Dispatcher) Run()
Run registers the workers and allocation of jobs
type WorkProcessor ¶
type WorkProcessor interface {
Handle(job interface{})
}
WorkProcessor should be able to process jobs that come in
type Worker ¶
type Worker struct { WorkerPool chan chan interface{} JobChannel chan interface{} Processor WorkProcessor // contains filtered or unexported fields }
Worker proccesses jobs via the processor interface
func NewWorker ¶
func NewWorker(workerPool chan chan interface{}) Worker
NewWorker bootstraps the job and quit channels
Click to show internal directories.
Click to hide internal directories.