Changeset 0.32.0 (#206)
This commit is contained in:
18
server/store/ratelimit_iface.go
Normal file
18
server/store/ratelimit_iface.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// RateLimitStore manages distributed rate limit counters.
|
||||
// v0.32.0: replaces in-memory token bucket for cross-pod rate limiting.
|
||||
type RateLimitStore interface {
|
||||
// Allow checks if a request is within the rate limit.
|
||||
// key is "{scope}:{identifier}" e.g. "auth:192.168.1.1".
|
||||
// Atomically increments the counter if allowed.
|
||||
Allow(ctx context.Context, key string, rate float64, burst int) (bool, error)
|
||||
|
||||
// Cleanup removes expired windows older than maxAge.
|
||||
Cleanup(ctx context.Context, maxAge time.Duration) error
|
||||
}
|
||||
Reference in New Issue
Block a user