applying feedback

This commit is contained in:
Gabriel mermelstein 2025-01-03 10:03:55 +01:00
parent 1ca365f69d
commit b3f1773eaa
No known key found for this signature in database
GPG Key ID: 82B8134785FEAE0D

View File

@ -383,21 +383,21 @@ func (rlc RateLimitsConfig) MarshalJSON() ([]byte, error) {
return json.Marshal(output) return json.Marshal(output)
} }
type RateLimitUnit string type RateLimitTimeUnit string
const Hour RateLimitUnit = "h" const Hour RateLimitTimeUnit = "h"
const Minute RateLimitUnit = "m" const Minute RateLimitTimeUnit = "m"
const Second RateLimitUnit = "s" const Second RateLimitTimeUnit = "s"
const Millisecond RateLimitUnit = "ms" const Millisecond RateLimitTimeUnit = "ms"
type RateLimit struct { type RateLimit struct {
Volume int Volume int // Number of allowed messages per period
Period int Period int // Length of each rate-limit period (in TimeUnit)
Unit RateLimitUnit TimeUnit RateLimitTimeUnit // Time unit of the period
} }
func (rl RateLimit) String() string { func (rl RateLimit) String() string {
return fmt.Sprintf("%d/%d%s", rl.Volume, rl.Period, rl.Unit) return fmt.Sprintf("%d/%d%s", rl.Volume, rl.Period, rl.TimeUnit)
} }
func (rl RateLimit) MarshalJSON() ([]byte, error) { func (rl RateLimit) MarshalJSON() ([]byte, error) {