package limiter
import "github.com/influxdata/influxdb/pkg/limiter"
Package limiter provides concurrency limiters.
Index ¶
- type Fixed
- func NewFixed(limit int) Fixed
- func (t Fixed) Available() int
- func (t Fixed) Capacity() int
- func (t Fixed) Idle() bool
- func (t Fixed) Release()
- func (t Fixed) Take()
- func (t Fixed) TryTake() bool
- type Rate
- type Writer
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.
func NewFixed ¶
func (Fixed) Available ¶
Available returns the number of available tokens that may be taken.
func (Fixed) Capacity ¶
Capacity returns the number of tokens can be taken.
func (Fixed) Idle ¶
Idle returns true if the limiter has all its capacity is available.
func (Fixed) Release ¶
func (t Fixed) Release()
Release releases a token back to the limiter.
func (Fixed) Take ¶
func (t Fixed) Take()
Take attempts to take a token and blocks until one is available.
func (Fixed) TryTake ¶
TryTake attempts to take a token and return true if successful, otherwise returns false.
type Rate ¶
func NewRate ¶
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.
func (*Writer) Close ¶
func (*Writer) Name ¶
func (*Writer) Sync ¶
func (*Writer) Write ¶
Write writes bytes from b.
Source Files ¶
- Version
- v1.12.0 (latest)
- Published
- Apr 8, 2025
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 2 days ago –
Tools for package owners.