hyperlane-plugin-concurrency 22.14.0

A lock-free atomic global and per-route-prefix in-flight concurrency limiter and adaptive load-shedding plugin for the Hyperlane framework with optional bounded Tokio Semaphore queuing, leak-proof RAII Context permits, and prebuilt 503 Retry-After wire responses.
Documentation
/// Context attribute key storing the active RAII [`ConcurrencyPermit`].
pub const ATTR_CONCURRENCY_PERMIT: &str = "hyperlane_plugin_concurrency_permit";

/// Default global maximum concurrent in-flight requests.
pub const DEFAULT_MAX_IN_FLIGHT: usize = 1_024;

/// Default `Retry-After` header value in seconds emitted on `503 Service Unavailable`.
pub const DEFAULT_RETRY_AFTER_SECS: u64 = 1;

/// Default rejection body emitted when concurrency capacity is saturated.
pub const DEFAULT_SHED_BODY: &[u8] = b"Service Unavailable";

/// Default `Content-Type` header emitted on shed responses.
pub const DEFAULT_SHED_CONTENT_TYPE: &str = "text/plain; charset=utf-8";

/// Default target request latency in milliseconds for AIMD adaptive load shedding.
pub const DEFAULT_ADAPTIVE_TARGET_LATENCY_MS: u64 = 100;

/// Default EWMA smoothing denominator (alpha = 1 / 8).
pub(crate) const EWMA_SHIFT: u32 = 3;

/// Microseconds per millisecond conversion factor.
pub(crate) const MICROS_PER_MS: u64 = 1_000;