Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Type string `yaml:"type" json:"type,omitempty" mapstructure:"type" default:"sliding_window"` DurationInSecond int `yaml:"duration_in_seconds" json:"duration_in_seconds,omitempty" mapstructure:"duration_in_seconds" default:"1"` NumberOfRequests int `yaml:"number_of_requests" json:"number_of_requests,omitempty" mapstructure:"number_of_requests" default:"20"` }
type IRateLimiter ¶
func NewSlidingWindowRateLimiter ¶
func NewSlidingWindowRateLimiter(rdb *redis.Client, logger *slog.Logger, rate *Rate) IRateLimiter
type RateLimiter ¶
type RateLimiter struct {
Limiter IRateLimiter
}
func NewRateLimiter ¶
func NewRateLimiter(rdb *redis.Client, logger *slog.Logger, rate *Rate, rltype string) *RateLimiter
type SlidingWindowCache ¶
type SlidingWindowCache interface {
Validate(keyname string, timestamp int64, window_start int64, limit int) bool
}
func NewRedisLogCache ¶
func NewRedisLogCache(logger *slog.Logger, client *redis.Client) SlidingWindowCache
type SlidingWindowRateLimiter ¶
type SlidingWindowRateLimiter struct {
// contains filtered or unexported fields
}
func (*SlidingWindowRateLimiter) Validate ¶
func (t *SlidingWindowRateLimiter) Validate(key string) bool
Click to show internal directories.
Click to hide internal directories.