resolveContextLimit picks the first positive value from metadata, configured limit, and fallback — in that priority order. Returns 0 when none are positive.
(metadataLimit, configLimit, fallback int64)
| 259 | // configured limit, and fallback — in that priority order. Returns |
| 260 | // 0 when none are positive. |
| 261 | func resolveContextLimit(metadataLimit, configLimit, fallback int64) int64 { |
| 262 | if metadataLimit > 0 { |
| 263 | return metadataLimit |
| 264 | } |
| 265 | if configLimit > 0 { |
| 266 | return configLimit |
| 267 | } |
| 268 | if fallback > 0 { |
| 269 | return fallback |
| 270 | } |
| 271 | return 0 |
| 272 | } |
| 273 | |
| 274 | // shouldCompact returns the usage percentage and whether it exceeds |
| 275 | // the threshold. Returns (0, false) when contextLimit is |