All checks were successful
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
18 lines
497 B
Go
18 lines
497 B
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// RateLimitStore manages distributed rate limit counters.
|
|
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
|
|
}
|