Codevault initial commit
This commit is contained in:
21
internal/config/ratelimit.go
Normal file
21
internal/config/ratelimit.go
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user