Documentation ¶
Index ¶
- Variables
- type Config
- type Dispatcher
- func (d *Dispatcher) AddTask(t Task) error
- func (d *Dispatcher) GetCurrentFreeWorkerNum() int
- func (d *Dispatcher) GetCurrentTaskTodoNum() int
- func (d *Dispatcher) GetMaxTaskNum() int
- func (d *Dispatcher) GetName() string
- func (d *Dispatcher) GetState() State
- func (d *Dispatcher) GetTotalDoneTask() uint64
- func (d *Dispatcher) GetTotalErrorTask() uint64
- func (d *Dispatcher) GetTotalInTask() uint64
- func (d *Dispatcher) GetTotalRefusedTask() uint64
- func (d *Dispatcher) GetTotalWorkNum() int
- func (d *Dispatcher) IsStop() bool
- func (d *Dispatcher) StartAgain()
- func (d *Dispatcher) Status()
- func (d *Dispatcher) StopForever(done chan struct{})
- func (d *Dispatcher) StopTemporary()
- type InData
- type OutData
- type Resource
- type State
- type Task
- type Worker
Constants ¶
This section is empty.
Variables ¶
var ErrorOfDispatcherHasStop = errors.New("dispatcher has stop")
ErrorOfDispatcherHasStop dispatcher is stop
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher job to worker to do.
func GetDispatch ¶
func GetDispatch(c Config, workDo workDoing, r Resource) *Dispatcher
GetDispatch Get a worker task queue model.
func (*Dispatcher) GetCurrentFreeWorkerNum ¶
func (d *Dispatcher) GetCurrentFreeWorkerNum() int
GetCurrentFreeWorkerNum get current free worker number.
func (*Dispatcher) GetCurrentTaskTodoNum ¶
func (d *Dispatcher) GetCurrentTaskTodoNum() int
GetCurrentTaskTodoNum get current job number wait to operate.
func (*Dispatcher) GetMaxTaskNum ¶
func (d *Dispatcher) GetMaxTaskNum() int
GetMaxTaskNum get max number of job queue.
func (*Dispatcher) GetTotalDoneTask ¶
func (d *Dispatcher) GetTotalDoneTask() uint64
GetTotalDoneTask get total number of job which all workers finish since dispatcher start.
func (*Dispatcher) GetTotalErrorTask ¶
func (d *Dispatcher) GetTotalErrorTask() uint64
GetTotalErrorTask get total number of job which all workers operate error since dispatcher start.
func (*Dispatcher) GetTotalInTask ¶
func (d *Dispatcher) GetTotalInTask() uint64
GetTotalInTask get total number of job which put in job queue since dispatcher start.
func (*Dispatcher) GetTotalRefusedTask ¶
func (d *Dispatcher) GetTotalRefusedTask() uint64
GetTotalRefusedTask get total number of job which refuse because of job queue full since dispatcher start.
func (*Dispatcher) GetTotalWorkNum ¶
func (d *Dispatcher) GetTotalWorkNum() int
GetTotalWorkNum get max number of worker.
func (*Dispatcher) Status ¶
func (d *Dispatcher) Status()
Status show the status of the current dispatcher.
func (*Dispatcher) StopForever ¶
func (d *Dispatcher) StopForever(done chan struct{})
StopForever dispatcher, not accept task any more, but should finish all task that in queue, then every worker will quit, can't be start again.
func (*Dispatcher) StopTemporary ¶
func (d *Dispatcher) StopTemporary()
StopTemporary dispatcher, not accept task any more, but should finish all task that in queue, can start again by call StartAgain().