ratelimiter
ratelimiter
import "github.com/cloudfoundry/go-cf-api/internal/apicommon/v3/ratelimiter"
Index
- Variables
- func NewRateLimiterMiddleware(generalRateLimiter, unauthenticatedRateLimiter RateLimiter) echo.MiddlewareFunc
- type RateLimiter
- type ResetInterval
- type rateLimiter
- type record
- type userHashResetInterval
Variables
var now = time.Now
func NewRateLimiterMiddleware
func NewRateLimiterMiddleware(generalRateLimiter, unauthenticatedRateLimiter RateLimiter) echo.MiddlewareFunc
type RateLimiter
type RateLimiter interface {
Check(identifier string) (bool, map[string]string, error)
Increment(identifier string)
}
func NewRateLimiter
func NewRateLimiter(globalLimit, perProcessLimit int, resetInterval ResetInterval) RateLimiter
type ResetInterval
type ResetInterval interface {
Next(identifier string) time.Time
}
func NewUserHashResetInterval
func NewUserHashResetInterval(interval time.Duration, now func() time.Time) ResetInterval
type rateLimiter
type rateLimiter struct {
mutex sync.Mutex
store map[string]*record
globalLimit int
perProcessLimit int
resetInterval ResetInterval
}
func (*rateLimiter) Check
func (r *rateLimiter) Check(identifier string) (bool, map[string]string, error)
func (*rateLimiter) Increment
func (r *rateLimiter) Increment(identifier string)
func (*rateLimiter) estimateRemaining
func (r *rateLimiter) estimateRemaining(count int) int
type record
type record struct {
count int
validUntil time.Time
}
type userHashResetInterval
type userHashResetInterval struct {
interval time.Duration
now func() time.Time
}
func (*userHashResetInterval) Next
func (u *userHashResetInterval) Next(identifier string) time.Time
Generated by gomarkdoc