middleware

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConcurrencyLimiter

func ConcurrencyLimiter(cfg ConcurrencyConfig) echo.MiddlewareFunc

ConcurrencyLimiter returns an Echo middleware that limits concurrent handler executions. Excess requests are queued up to MaxQueueSize. Requests that cannot enter the queue receive 503 (SERVER_BUSY). Requests that wait longer than QueueTimeout receive 503 (SERVER_BUSY).

func MetricsHandler added in v0.5.0

func MetricsHandler(metrics *ConcurrencyMetrics, maxConcurrency, maxQueueSize int) echo.HandlerFunc

MetricsHandler returns an Echo handler that renders Prometheus text exposition format for the sandbox concurrency and queue gauges.

Types

type ConcurrencyConfig

type ConcurrencyConfig struct {
	MaxConcurrency int
	MaxQueueSize   int
	QueueTimeout   time.Duration
	Metrics        *ConcurrencyMetrics
}

ConcurrencyConfig holds parameters for the concurrency limiter middleware.

type ConcurrencyMetrics added in v0.5.0

type ConcurrencyMetrics struct {
	Active atomic.Int64
	Queued atomic.Int64
}

ConcurrencyMetrics exposes live concurrency and queue counters for external consumption (e.g. Prometheus /metrics endpoint).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL