Documentation
¶
Index ¶
- type Executor
- type InlineableRequest
- type Request
- type WorkPoolExecutor
- func (p *WorkPoolExecutor) Configure(params WorkPoolExecutorParams) error
- func (p *WorkPoolExecutor) HighWaterMark() int
- func (p *WorkPoolExecutor) NumWorkers() int
- func (p *WorkPoolExecutor) Params() WorkPoolExecutorParams
- func (p *WorkPoolExecutor) Process(req Request) *sync.WaitGroup
- func (p *WorkPoolExecutor) ProcessWithWaitGroup(r Request, wg *sync.WaitGroup)
- func (p *WorkPoolExecutor) Size() int
- type WorkPoolExecutorParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InlineableRequest ¶
type InlineableRequest interface { Request CanExecuteInline() }
If the request implements the InlineableRequest interface, the executor may process the request using the Process/ProcessWithGroupGroup's caller goroutine.
NOTE: The executor will only look at the CanExecuteInline method signature (it will not invoke the method).
type Request ¶
type Request interface { // The executor will call this method to serve the request. Execute() // The executor will call this method if the executor cannot serve the // request. Cancel should be a cheap operation than Execute. Cancel() }
type WorkPoolExecutor ¶
type WorkPoolExecutor struct {
// contains filtered or unexported fields
}
Process requests using a fixed number of workers (when configured) to limit concurrency. Requests are processed in LIFO order.
NOTE: When the number of workers is set to unlimited, the executor may process the request using the Process/ProcessWithWaitGroup's caller goroutine if the request implements the InlineableRequest interface.
func NewWorkPoolExecutor ¶
func NewWorkPoolExecutor() *WorkPoolExecutor
func (*WorkPoolExecutor) Configure ¶
func (p *WorkPoolExecutor) Configure(params WorkPoolExecutorParams) error
func (*WorkPoolExecutor) HighWaterMark ¶
func (p *WorkPoolExecutor) HighWaterMark() int
func (*WorkPoolExecutor) NumWorkers ¶
func (p *WorkPoolExecutor) NumWorkers() int
func (*WorkPoolExecutor) Params ¶
func (p *WorkPoolExecutor) Params() WorkPoolExecutorParams
func (*WorkPoolExecutor) ProcessWithWaitGroup ¶
func (p *WorkPoolExecutor) ProcessWithWaitGroup(r Request, wg *sync.WaitGroup)
func (*WorkPoolExecutor) Size ¶
func (p *WorkPoolExecutor) Size() int
type WorkPoolExecutorParams ¶
type WorkPoolExecutorParams struct { // The number of worker in this pool. Non-positive means unlimited. NumWorkers int // The amount of time a request can be in the queue before the request // gets cancelled. If the value is non-positive, timeout is disabled. QueueTimeout time.Duration // How frequent should the work pool sweeps timed out requests from its // queue. CheckInterval must by positive when QueueTimeout is enabled. CheckInterval time.Duration }
Click to show internal directories.
Click to hide internal directories.