ratelimit

package
v0.0.0-...-5019c65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseRate

func ParseRate(rate string) (count int, interval time.Duration, err error)

ParseRate parses rate in form of "N/D", e.g "10/1s" or "100/1ms"

Types

type Limiter

type Limiter struct {
	// contains filtered or unexported fields
}

Limiter is precise rate limiter with context support.

func NewLimiter

func NewLimiter(maxCount int, interval time.Duration) *Limiter

NewLimiter returns limiter that throttles rate of successful Acquire() calls to maxSize events at any given interval.

func (*Limiter) Acquire

func (l *Limiter) Acquire(ctx context.Context) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL