| 177 | } |
| 178 | |
| 179 | func parseFlags() benchmarkConfig { |
| 180 | cfg := benchmarkConfig{} |
| 181 | flag.StringVar(&cfg.configPath, "config", "", "Optional path to ledgerforge config file. Only the redis section is read.") |
| 182 | flag.StringVar(&cfg.redisDSN, "redis-dsn", "", "Redis DSN. Overrides LEDGERFORGE_REDIS_DNS and config file.") |
| 183 | flag.BoolVar(&cfg.redisSkipTLS, "redis-skip-tls-verify", false, "Skip TLS verification for Redis when using -redis-dsn.") |
| 184 | flag.StringVar(&cfg.outPath, "out", "tests/loadtest/queue-summary.json", "Output path for the generated summary JSON.") |
| 185 | flag.StringVar(&cfg.queueNames, "queues", "", "Comma-separated queue names to track.") |
| 186 | flag.StringVar(&cfg.queuePrefix, "queue-prefix", "", "Track all queues whose name starts with this prefix.") |
| 187 | flag.StringVar(&cfg.queuePrefixes, "queue-prefixes", "", "Comma-separated queue prefixes to track.") |
| 188 | flag.StringVar(&cfg.label, "label", "queue_drain", "Scenario label to embed in the generated summary.") |
| 189 | flag.DurationVar(&cfg.interval, "interval", time.Second, "Polling interval for queue inspection.") |
| 190 | flag.DurationVar(&cfg.timeout, "timeout", 15*time.Minute, "Maximum benchmark duration.") |
| 191 | flag.BoolVar(&cfg.wait, "wait", false, "Wait for backlog to appear before starting the benchmark.") |
| 192 | flag.Parse() |
| 193 | |
| 194 | if strings.TrimSpace(cfg.queueNames) == "" && strings.TrimSpace(cfg.queuePrefix) == "" && strings.TrimSpace(cfg.queuePrefixes) == "" { |
| 195 | exitf("either -queues, -queue-prefix, or -queue-prefixes must be set") |
| 196 | } |
| 197 | if cfg.interval <= 0 { |
| 198 | exitf("interval must be greater than zero") |
| 199 | } |
| 200 | if cfg.timeout <= 0 { |
| 201 | exitf("timeout must be greater than zero") |
| 202 | } |
| 203 | return cfg |
| 204 | } |
| 205 | |
| 206 | func resolveRedisSettings(cfg benchmarkConfig) (dsn string, skipTLSVerify bool, err error) { |
| 207 | if strings.TrimSpace(cfg.redisDSN) != "" { |