Documentation ¶
Overview ¶
Package rate provides a rate-limiter with a special algorithm.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns a new instance of the rate limiter with certain a algorithm.
a nil result means the algorithm of yours has not been registered, so you might:
- use a right algorithm name such as rate.LeakyBucket, rate.TokenBucket - or register yours implement with rate.Register and assign it by algorithm name.
func Register ¶
func Register(algorithm string, generator func(maxCount int64, d time.Duration) rateapi.Limiter) error
Register puts your generator into registry so it will be assign from New() in the future
func Unregister ¶
func Unregister(algorithm Algorithm)
Unregister deregister a limiter generator by algorithm name.
Types ¶
Directories ¶
Path | Synopsis |
---|---|
_examples
|
|
Package counter implements counter algorithm
|
Package counter implements counter algorithm |
internal
|
|
Package leakybucket implements leaky-bucket algorithm
|
Package leakybucket implements leaky-bucket algorithm |
pkg
|
|
logger
package logger is a minimal logger weapper
|
package logger is a minimal logger weapper |
Package rateapi provides the basic interfaces of hedzr/rate packages.
|
Package rateapi provides the basic interfaces of hedzr/rate packages. |
Package tokenbucket implements token-bucket algorithm
|
Package tokenbucket implements token-bucket algorithm |
Click to show internal directories.
Click to hide internal directories.