Documentation ¶
Index ¶
- type Handler
- type Logger
- type Pool
- func (p *Pool) AddJob(value ...interface{})
- func (p *Pool) AddWorker(n int, handler Handler, start ...bool)
- func (p *Pool) Close()
- func (p *Pool) CloseGracefully()
- func (p *Pool) ErrorCount() int
- func (p *Pool) GetErrorPool() <-chan *WorkerJob
- func (p *Pool) GetStats() string
- func (p *Pool) PoolCap() int
- func (p *Pool) PoolLen() int
- func (p *Pool) RetryCount() int
- func (p *Pool) SetBatchProfiler(batchSize int)
- func (p *Pool) SetConsoleLog(enable bool)
- func (p *Pool) SetLogger(logger Logger)
- func (p *Pool) SetMaxRetry(n int)
- func (p *Pool) SetRetryExponent(n float64)
- func (p *Pool) SetTag(tag string)
- func (p *Pool) SetTimeProfiler(dur time.Duration)
- func (p *Pool) Start()
- func (p *Pool) Stats()
- func (p *Pool) SuccessCount() int
- func (p *Pool) TotalCount() int
- func (p *Pool) WorkerCount() int
- type Worker
- type WorkerJob
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool struct { Tag string //tag used to identify a pool // contains filtered or unexported fields }
Pool contains the jobs
func NewPool ¶
NewPool will create new pool
Example ¶
pool := NewPool(1, "Tag", myLogger{}) pool.AddWorker(2, egPrint, true) pool.AddJob(1) pool.Close() fmt.Println(pool.GetStats())
Output: Tag: Woker 2 Jobs: Total 1 Success 1 Error 0 Retry 0
func NewSimplePool ¶
NewSimplePool will create new pool without any logger and tag
Example ¶
pool := NewSimplePool(1) pool.AddWorker(2, egPrint, true) pool.AddJob(1) pool.Close() fmt.Println(pool.GetStats())
Output: Pool: Woker 2 Jobs: Total 1 Success 1 Error 0 Retry 0
func (*Pool) AddJob ¶
func (p *Pool) AddJob(value ...interface{})
AddJob will enqueue job in the pool
func (*Pool) AddWorker ¶
AddWorker will add worker in the pool. If start value is true then it will immediately start the worker as well
func (*Pool) CloseGracefully ¶
func (p *Pool) CloseGracefully()
CloseGracefully will terminate all worker gracefully
func (*Pool) GetErrorPool ¶
GetErrorPool will return error pool if any error occurred then worker will push that error on error pool
func (*Pool) SetBatchProfiler ¶
SetBatchProfiler will set profiler by job processed batch will fill print/log the job done in given batch size
func (*Pool) SetConsoleLog ¶
SetConsoleLog will enable/disable console logging
func (*Pool) SetMaxRetry ¶
SetMaxRetry will set max retries for jobs. Default value is 0
func (*Pool) SetRetryExponent ¶
SetRetryExponent will set retry exponential base value
func (*Pool) SetTimeProfiler ¶
SetTimeProfiler will set profiler by time
func (*Pool) SuccessCount ¶
SuccessCount will return success count
type Worker ¶
type Worker struct { ID int //worker ID // contains filtered or unexported fields }
Worker will perform the job