Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct { JobQueue chan IJob // contains filtered or unexported fields }
Dispatcher holds worker pool, job queue and manages workers and job To submit a job to worker pool, use code `dispatcher.JobQueue <- job`
func NewDispatcher ¶
func NewDispatcher(dispatcherName string, options ...Option) *Dispatcher
NewDispatcher : returns a new dispatcher. When no options are given, it returns a dispatcher with default settings 10 Workers and `newWorker` initialisation and default logger which logs to graylog @ 127.0.0.1:11100. This is not in use. So it is prety much useless. Set log level to INFO to track max used workers.
func (*Dispatcher) ResetDispatcherMaxWorkerUsed ¶
func (d *Dispatcher) ResetDispatcherMaxWorkerUsed()
ResetDispatcherMaxWorkerUsed should be called whenever the max worker count needs to be reset
type Option ¶
type Option func(d *Dispatcher)
Option sets a parameter for the Dispatcher
func SetJobQueue ¶
SetJobQueue sets the JobQueue in dispatcher
func SetLatencyLogger ¶
func SetLatencyLogger(logger gologger.IMultiLogger) Option
SetLatencyLogger sets the latency logger for the dispatcher This should be set in order to get the max worker count
func SetLogger ¶
func SetLogger(logger *gologger.CustomLogger) Option
SetLogger sets the logger in dispatcher
func SetMaxWorkers ¶
SetMaxWorkers sets the number of workers. Default is 10
type Worker ¶
type Worker struct { WorkerPool chan chan IJob // A pool of workers channels that are registered in the dispatcher JobChannel chan IJob // Channel through which a job is received by the worker Quit chan bool // Channel for Quit signal WorkerNumber int // Worker Number }
Worker : Default Worker implementation