Documentation
¶
Overview ¶
Package tokenbucket implements the Token Bucket rate limiting algorithm.
Token Bucket allows bursty traffic up to the bucket capacity while continuously refilling tokens at a constant rate.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Strategy ¶
type Strategy struct{}
Strategy implements the algorithm.Algorithm interface for Token Bucket.
func (*Strategy) EvaluateMemory ¶
func (s *Strategy) EvaluateMemory(now time.Time, state *algorithm.State, limit int64, window time.Duration) algorithm.Result
EvaluateMemory evaluates the token bucket rate limit state synchronously in RAM. Note: This method expects state modification to be guarded by a mutex from the caller.
func (*Strategy) RedisScript ¶
RedisScript returns the high-performance atomic Lua script for Redis distribution.
Click to show internal directories.
Click to hide internal directories.