Documentation
¶
Overview ¶
Package leakybucket implements the Leaky Bucket rate limiting algorithm for traffic shaping.
Unlike Token Bucket which permits sudden request bursts, Leaky Bucket enforces a smooth, constant outflow rate. Requests that exceed the bucket capacity are immediately rejected.
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 Leaky Bucket.
func (*Strategy) EvaluateMemory ¶
func (s *Strategy) EvaluateMemory(now time.Time, state *algorithm.State, limit int64, window time.Duration) algorithm.Result
EvaluateMemory evaluates the leaky bucket rate limit state synchronously in RAM. state.Tokens digunakan untuk merepresentasikan level "air" (water level) saat ini.
func (*Strategy) RedisScript ¶
RedisScript returns the atomic Lua script for Redis execution.
Click to show internal directories.
Click to hide internal directories.