Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Request ¶
type Request interface {
Invoke() (interface{}, error)
}
Request is a request that's submitted to the worker pool for processing.
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool manages a pool of workers that processes requests concurrently and, at the end, gathers the responses.
func NewWorkerPool ¶
func NewWorkerPool(num int, logger log.Logger) *WorkerPool
NewWorkerPool returns a new worker pool with the given number of workers.
func (*WorkerPool) Responses ¶
func (p *WorkerPool) Responses() []*Response
Responses contains the responses after the pool is stopped.
func (*WorkerPool) Start ¶
func (p *WorkerPool) Start()
Start starts all the workers and listens for responses.
func (*WorkerPool) Stop ¶
func (p *WorkerPool) Stop()
Stop stops the workers in the pool and stops listening for responses.
func (*WorkerPool) Submit ¶
func (p *WorkerPool) Submit(req Request)
Submit submits a request for processing.
Click to show internal directories.
Click to hide internal directories.