cache: Per-client fair-share bandwidth on table uplink
CI / vulncheck (pull_request) Successful in 20s
CI / check-and-test (pull_request) Failing after 21s

This commit is contained in:
2026-09-09 20:22:23 +00:00
parent 50ca0a071c
commit b7710de0ca
13 changed files with 439 additions and 18 deletions
+12
View File
@@ -22,6 +22,8 @@ var (
maxConcurrentRequests int64
maxRequestsPerClient int64
uplinkBandwidth string
maxBytesPerClientPerSec int64
)
var rootCmd = &cobra.Command{
@@ -107,6 +109,12 @@ var rootCmd = &cobra.Command{
if maxRequestsPerClient > 0 {
finalMaxRequestsPerClient = maxRequestsPerClient
}
if uplinkBandwidth != "" {
cfg.UplinkBandwidth = uplinkBandwidth
}
if maxBytesPerClientPerSec > 0 {
cfg.MaxBytesPerClientPerSec = maxBytesPerClientPerSec
}
// Validate after loading and applying CLI overrides (fail fast, do not create default on validate error)
if err := cfg.Validate(); err != nil {
@@ -130,6 +138,8 @@ var rootCmd = &cobra.Command{
cfg.MaxObjectSize,
cfg.TrustedProxies,
cfg.Cache.NegativeTTL,
cfg.UplinkBandwidth,
cfg.MaxBytesPerClientPerSec,
)
if err != nil {
logger.Logger.Error().
@@ -170,4 +180,6 @@ func init() {
rootCmd.Flags().Int64Var(&maxConcurrentRequests, "max-concurrent-requests", 0, "Maximum concurrent requests (0 = use config file value)")
rootCmd.Flags().Int64Var(&maxRequestsPerClient, "max-requests-per-client", 0, "Maximum concurrent requests per client IP (0 = use config file value)")
rootCmd.Flags().StringVar(&uplinkBandwidth, "uplink-bandwidth", "", "Table uplink bandwidth bytes/sec human size e.g. 10MB (empty = use config; 0 disables)")
rootCmd.Flags().Int64Var(&maxBytesPerClientPerSec, "max-bytes-per-client-per-sec", 0, "Absolute per-client bytes/sec cap (0 = use config file value)")
}