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 JobSize int // job buffer size WorkerIdleTimeout time.Duration // worker 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) 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.
func WithWorkerIdleTimeout ¶
WithWorkerIdleTimeout configures wrker idle timeout.
type Worker ¶
type Worker struct { Jobs chan *Job // contains filtered or unexported fields }
func NewWorker ¶
func NewWorker(d *Dispatcher) *Worker
func (*Worker) LastBusyTime ¶
func (*Worker) SetLastBusyTime ¶
func (w *Worker) SetLastBusyTime()
func (*Worker) SetRunning ¶
Click to show internal directories.
Click to hide internal directories.