22 lines
381 B
Go
22 lines
381 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
type RateLimitConfig struct {
|
|
MaxFailures int `yaml:"max_failures"`
|
|
Window time.Duration `yaml:"window"`
|
|
}
|
|
|
|
func (rc *RateLimitConfig) Validate() error {
|
|
if rc.MaxFailures <= 0 {
|
|
return fmt.Errorf("max_failures must be positive")
|
|
}
|
|
if rc.Window <= 0 {
|
|
return fmt.Errorf("window must be positive")
|
|
}
|
|
return nil
|
|
}
|