ratelimiter

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimiter

type RateLimiter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

TODO consider making this also perform rate limiting with priority, so more important events take priority; also consider using or making its ICD like golang.org/x/time/rate

func New

func New(requestsPerSecond float64) *RateLimiter

func (*RateLimiter) Take

func (t *RateLimiter) Take(ctx context.Context) error

func (*RateLimiter) TakeMore

func (t *RateLimiter) TakeMore(ctx context.Context, rateBlocksBefore, rateBlocksAfter int) error

func (*RateLimiter) TimePerRequests

func (rl *RateLimiter) TimePerRequests() time.Duration

Jump to

Keyboard shortcuts

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