@@ -3,6 +3,8 @@ package config
33import (
44 "cmp"
55 "fmt"
6+
7+ "github.com/alecthomas/units"
68)
79
810type validateFn func () error
@@ -68,6 +70,8 @@ func (c *Config) storeValidations() []validateFn {
6870
6971 inRange ("compression.sealed_zstd_compression_level" , - 7 , 22 , c .Compression .SealedZstdCompressionLevel ),
7072 inRange ("compression.doc_block_zstd_compression_level" , - 7 , 22 , c .Compression .DocBlockZstdCompressionLevel ),
73+ greaterThan ("compression.lid_block_cap" , 0 , c .Compression .LIDBlockSize ),
74+ lessOrEqThan ("compression.lid_block_cap" , int (64 * units .KiB ), int (c .Compression .LIDBlockSize )),
7175 inRange ("offloading.queue_size_percent" , 0 , 100 , c .Offloading .QueueSizePercent ),
7276
7377 greaterThan ("experimental.max_regex_tokens_check" , - 1 , c .Experimental .MaxRegexTokensCheck ),
@@ -106,6 +110,18 @@ func greaterThan[T cmp.Ordered](field string, base, v T) validateFn {
106110 }
107111}
108112
113+ func lessOrEqThan [T cmp.Ordered ](field string , base , v T ) validateFn {
114+ return func () error {
115+ if v > base {
116+ return fmt .Errorf (
117+ "field %q must be greater than %v" ,
118+ field , base ,
119+ )
120+ }
121+ return nil
122+ }
123+ }
124+
109125func inRange [T cmp.Ordered ](field string , from , to , v T ) validateFn {
110126 return func () error {
111127 if v < from || to < v {
0 commit comments