Documentation
¶
Index ¶
- type Dispatcher
- func (d *Dispatcher) AddWork(data Treator)
- func (d *Dispatcher) ErrorCount() int
- func (d *Dispatcher) FillWork(data Treator, queueLimit int, checkInterval time.Duration)
- func (d *Dispatcher) QueueLen() int
- func (d *Dispatcher) Run()
- func (d *Dispatcher) SetMaxWorkers(n int)
- func (d *Dispatcher) Stop()
- func (d *Dispatcher) TasksDone() int
- func (d *Dispatcher) WaitUntilNoTasks(period time.Duration)
- func (d *Dispatcher) Workers() int
- type OnResultFunc
- type Result
- type Treator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher implements a task-dispatching functionality
func New ¶
func New(max int, onResultFunc OnResultFunc) *Dispatcher
New returns new dispatcher with max workers
func (*Dispatcher) AddWork ¶
func (d *Dispatcher) AddWork(data Treator)
AddWork adds work with data to the dispatcher
func (*Dispatcher) ErrorCount ¶
func (d *Dispatcher) ErrorCount() int
ErrorCount returns an error count
func (*Dispatcher) FillWork ¶
func (d *Dispatcher) FillWork(data Treator, queueLimit int, checkInterval time.Duration)
FillWork adds work with data to the dispatcher after queue size will fall below queueLimit value, check it every checkInterval
func (*Dispatcher) QueueLen ¶
func (d *Dispatcher) QueueLen() int
QueueLen returns current length of the queue
func (*Dispatcher) TasksDone ¶
func (d *Dispatcher) TasksDone() int
TasksDone returns done tasks count
func (*Dispatcher) WaitUntilNoTasks ¶
func (d *Dispatcher) WaitUntilNoTasks(period time.Duration)
WaitUntilNoTasks stops the dispatcher making checks for "0 tasks now" every period
func (*Dispatcher) Workers ¶
func (d *Dispatcher) Workers() int
Workers returns current worker count
type OnResultFunc ¶
type OnResultFunc func(result Result)
OnResultFunc is a func to do something with task result on it's finish
