Skip to main content

hyperlane_plugin_concurrency/
lib.rs

1//! hyperlane-plugin-concurrency
2//!
3//! Lock-free atomic global and per-route-prefix in-flight concurrency limiter
4//! and adaptive load-shedding plugin for Hyperlane with optional bounded
5//! `tokio::sync::Semaphore` queuing, leak-proof RAII `Context` permits, and
6//! prebuilt `503 Service Unavailable` wire responses.
7
8mod r#const;
9mod r#enum;
10mod r#fn;
11mod r#impl;
12mod r#static;
13mod r#struct;
14
15#[cfg(test)]
16#[path = "../tests/mod.rs"]
17mod tests;
18
19pub use {r#const::*, r#enum::*, r#struct::*};
20
21pub(crate) use {r#fn::*, r#static::*};
22
23use std::{
24    cmp::Reverse,
25    sync::{
26        Arc, Mutex, OnceLock,
27        atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering},
28    },
29    time::{Duration, Instant},
30};
31
32use {
33    hyperlane::{
34        CONTENT_TYPE, Context, HashSetXxHash3_64, HttpStatus, RETRY_AFTER, Response, ResponseError,
35        ServerHook, Status, Stream, hash_set_xx_hash3_64,
36        tokio::{
37            sync::{OwnedSemaphorePermit, Semaphore},
38            time::timeout,
39        },
40    },
41    lombok_macros::*,
42};