Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct { MaxWorkerNum int // maximum worker num in the pool MaxJobRunningTimeout time.Duration // job execution timeout WorkerPool chan *Worker // worker pool // contains filtered or unexported fields }
Dispatcher takes the responsibility of dispatching jobs to available workers.
func (*Dispatcher) EnableDebug ¶ added in v0.2.1
func (d *Dispatcher) EnableDebug()
EnableDebug enables debug info.
func (*Dispatcher) NewWorker ¶ added in v0.2.3
func (d *Dispatcher) NewWorker() *Worker
NewWorker 生成一个工作协程
func (*Dispatcher) RunningWorkerNum ¶
func (d *Dispatcher) RunningWorkerNum() int
RunningWorkerNum returns the current running worker num.
func (*Dispatcher) Submit ¶ added in v0.2.0
func (d *Dispatcher) Submit(j *Job)
Submit submits a job.
type Setter ¶
type Setter func(d *Dispatcher) error
Setter configures a Dispatcher.
func WithMaxWorkerNum ¶
WithMaxWorkerNum configures maximum number of workers in the pool.
Click to show internal directories.
Click to hide internal directories.