Files
job-search/internal/config/conf_ratelimitrule.go
T
bwilliams 0b5fde9563 Config changes
- a source's interval must be greater than 0: a source is turned off with
  enabled, not with a zero interval, so JSCSourcesSource rejects an interval of
  0 or less (its validate is promoted to each source's section);
- max_message_size rejects -1: JSCServerWebSocket rejects a max_message_size
  of -1 (util.ByteSizeNoLimit), as a client could then exhaust the server's
  memory;
- every setting documents what 0 or empty means (zero/none, no limit or a
  default).
2026-10-15 16:00:48 +01:00

32 lines
995 B
Go

package config
import "reflect"
// JSCRateLimitRule configures one rate limit: PerSecond sustained, with
// bursts of up to Burst. It is off unless Enabled and PerSecond is greater
// than 0; a Burst below 1 means 1. The type is used under several keys so it
// has no JSCK* constant and its Flatten keys are not prefixed.
type JSCRateLimitRule struct {
Enabled bool `cfg:"enabled" default:"false"`
PerSecond int `cfg:"per_second" default:"50"`
Burst int `cfg:"burst" default:"100"`
}
// ---------- Section methods (see Section) ----------
func (c JSCRateLimitRule) Map() map[string]any { return mapOf(c) }
func (c JSCRateLimitRule) Flatten() map[string]any { return flattenOf("", c) }
func (c JSCRateLimitRule) TypeOf(key string) (reflect.Kind, error) {
return typeOf(c, key)
}
func (c JSCRateLimitRule) ValueOf(key string) (any, error) {
return valueOf(c, key)
}
func (c *JSCRateLimitRule) SetValue(key string, value any) error {
return setValue(c, key, value)
}