Documentation ¶
Overview ¶
Package pool provides a simple worker pool with optional throttling of job processing
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
A Job is the basic unit of work for the pool.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
A Pool represents a set of background workers sharing a common work queue. Each worker is a goroutine and all workers attempt to receive jobs on a common channel. The pool can optionally be rate-limited to a set number of jobs / second, with configurable bursts.
func NewPool ¶
NewPool creates a new pool of n workers that process the queue as fast as possible, without rate limitation.
func NewRateLimitedPool ¶
NewRateLimitedPool create a new Pool of n workers processing at most rate jobs / second. If burst > 1, up to burst tokens can accumulate letting the pool temporarily exceed the rate until the saved tokens are all consumed. Tokens accumulate when requests are submitted at a rate slower than the processing rate.