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 InitializeDefaultDispatcher ¶
func InitializeDefaultDispatcher(maxWorkers int) *Dispatcher
InitializeDefaultDispatcher : Dispatcher using Default worker This method will be deprecated. Use NewDispatcher(options) instead
func InitializeDispatcher ¶
func InitializeDispatcher(customWorker func(chan chan IJob, int) IWorker, maxWorkers int) *Dispatcher
InitializeDispatcher : Dispatcher using custom implementation of the worker This method will be deprecated. Use NewDispatcher(options) instead
func NewDispatcher ¶
func NewDispatcher(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.
type Option ¶
type Option func(d *Dispatcher)
Option sets a parameter for the Dispatcher
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