Documentation ¶
Overview ¶
Package limiter provides concurrency limiters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fixed ¶
type Fixed chan struct{}
Fixed is a simple channel-based concurrency limiter. It uses a fixed size channel to limit callers from proceeding until there is a value available in the channel. If all are in-use, the caller blocks until one is freed.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
func NewWriter ¶
func NewWriter(w io.WriteCloser, bytesPerSec, burstLimit int) *Writer
NewWriter returns a writer that implements io.Writer with rate limiting. The limiter use a token bucket approach and limits the rate to bytesPerSec with a maximum burst of burstLimit.
func NewWriterWithRate ¶
func NewWriterWithRate(w io.WriteCloser, limiter Rate) *Writer
WithRate returns a Writer with the specified rate limiter.
Click to show internal directories.
Click to hide internal directories.