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 JobSize int WorkerIdleTimeout time.Duration MaxJobRunningTimeout time.Duration WorkerPool chan *Worker // contains filtered or unexported fields }
func New ¶
func New(setters ...Setter) (*Dispatcher, error)
func (*Dispatcher) Add ¶
func (d *Dispatcher) Add(w *Worker)
func (*Dispatcher) Remove ¶
func (d *Dispatcher) Remove(w *Worker)
func (*Dispatcher) RunningWorkerNum ¶
func (d *Dispatcher) RunningWorkerNum() int
func (*Dispatcher) SubmitAsync ¶
func (d *Dispatcher) SubmitAsync(j *Job)
type Setter ¶
type Setter func(d *Dispatcher) error
Setter configures a Dispatcher.
func WithJobSize ¶
func WithMaxWorkerNum ¶
WithMaxWorkerNum configures maximum number of workers in the pool.
func WithMonitor ¶
func WithWorkerIdleTimeout ¶
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.