forked from mtusi2026/mtusi2026lab7
19 lines
385 B
Go
19 lines
385 B
Go
package ratelimit
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type Limit struct {
|
|
Key string
|
|
Count int
|
|
Window time.Duration
|
|
}
|
|
|
|
// Reserve admits all dimensions atomically. A positive retryAfter rejects the
|
|
// reservation without consuming any dimension; errors must fail closed.
|
|
type Limiter interface {
|
|
Reserve(ctx context.Context, limits []Limit) (retryAfter time.Duration, err error)
|
|
}
|