File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,6 +132,13 @@ type Config struct {
132132 // in-flight requests to complete before forcing shutdown. Env:
133133 // GRACEFUL_SHUTDOWN_TIMEOUT (default: DefaultGracefulShutdownTimeout).
134134 GracefulShutdownTimeout int // seconds
135+ // ConcurrencyCapsPath is the path to the per-endpoint concurrency caps YAML
136+ // configuration file. When empty, concurrency shedding is disabled.
137+ // Env: CONCURRENCY_CAPS_PATH (default: "" — disabled; set to deploy/concurrency-caps.yaml to enable)
138+ ConcurrencyCapsPath string
139+
140+ // OTelLogsEnabled toggles OpenTelemetry log export (env: OTEL_LOGS_ENABLED).
141+ OTelLogsEnabled bool
135142}
136143
137144// ValidationResult holds the result of configuration validation
@@ -282,6 +289,7 @@ func Load(opts ...Option) (Config, error) {
282289 DBStatementCacheMode : DefaultDBStatementCacheMode ,
283290 PgBouncerIdleInTxTimeout : DefaultPgBouncerIdleInTxTimeout ,
284291 GracefulShutdownTimeout : DefaultGracefulShutdownTimeout ,
292+ ConcurrencyCapsPath : getEnv ("CONCURRENCY_CAPS_PATH" , "" ),
285293 }
286294
287295 // Resolve secrets through the provider
Original file line number Diff line number Diff line change @@ -52,6 +52,16 @@ func Register(r *gin.Engine) {
5252 r .Use (middleware .TailSamplingSignals ())
5353 r .Use (middleware .TraceIDMiddleware ())
5454
55+ // Per-endpoint concurrency shedding — shed excess load before rate limiting
56+ if cfg .ConcurrencyCapsPath != "" {
57+ concCfg , err := middleware .LoadConcurrencyConfig (cfg .ConcurrencyCapsPath )
58+ if err != nil {
59+ fmt .Printf ("WARNING: failed to load concurrency caps config from %s: %v\n " , cfg .ConcurrencyCapsPath , err )
60+ } else {
61+ r .Use (middleware .InflightMiddleware (concCfg ))
62+ }
63+ }
64+
5565 // Rate limiting
5666 rateLimitConfig := middleware.RateLimiterConfig {
5767 Enabled : cfg .RateLimitEnabled ,
You can’t perform that action at this time.
0 commit comments