@@ -12,9 +12,10 @@ import (
12
12
)
13
13
14
14
const (
15
- DefaultActiveWindow = 1 * time .Hour
15
+ DefaultActiveWindow = 2 * time .Hour
16
16
DefaultRateWindow = 5 * time .Minute
17
17
DefaultBucketSize = 1 * time .Minute
18
+ DefaultEvictInterval = 30 * time .Minute
18
19
DefaultNumPartitions = 64
19
20
)
20
21
@@ -38,6 +39,9 @@ type Config struct {
38
39
// memory.
39
40
BucketSize time.Duration `yaml:"bucket_size"`
40
41
42
+ // EvictionInterval defines the interval at which old streams are evicted.
43
+ EvictionInterval time.Duration `yaml:"eviction_interval"`
44
+
41
45
// The number of partitions for the Kafka topic used to read and write stream metadata.
42
46
// It is fixed, not a maximum.
43
47
NumPartitions int `yaml:"num_partitions"`
@@ -77,6 +81,12 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
77
81
DefaultBucketSize ,
78
82
"The size of the buckets used to calculate stream rates. Smaller buckets provide more precise rates but require more memory." ,
79
83
)
84
+ f .DurationVar (
85
+ & cfg .EvictionInterval ,
86
+ "ingest-limits.eviction-interval" ,
87
+ DefaultEvictInterval ,
88
+ "The interval at which old streams are evicted." ,
89
+ )
80
90
f .IntVar (
81
91
& cfg .NumPartitions ,
82
92
"ingest-limits.num-partitions" ,
@@ -98,6 +108,9 @@ func (cfg *Config) Validate() error {
98
108
if cfg .RateWindow < cfg .BucketSize {
99
109
return errors .New ("rate-window must be greater than or equal to bucket-size" )
100
110
}
111
+ if cfg .EvictionInterval <= 0 {
112
+ return errors .New ("eviction-interval must be greater than 0" )
113
+ }
101
114
if cfg .NumPartitions <= 0 {
102
115
return errors .New ("num-partitions must be greater than 0" )
103
116
}
0 commit comments