pub mod config;
pub mod dedup;
pub mod registry;
pub mod routing;
use std::num::NonZeroU32;
use governor::clock::DefaultClock;
use governor::state::keyed::DashMapStateStore;
use governor::{Quota, RateLimiter};
pub use config::{
BackpressureConfig, ChannelCacheConfig, ChannelConfig, ChannelCorsConfig,
ChannelRateLimitConfig, DeduplicationConfig,
};
pub use dedup::DeduplicationStore;
pub use registry::{ChannelRegistry, ChannelRuntimeConfig};
pub use routing::{RouteMatch, RouteTable};
pub type KeyedLimiter = RateLimiter<String, DashMapStateStore<String>, DefaultClock>;
pub fn build_keyed_limiter(rps: u32, burst: u32) -> KeyedLimiter {
let quota = Quota::per_second(NonZeroU32::new(rps).unwrap_or(NonZeroU32::MIN))
.allow_burst(NonZeroU32::new(burst).unwrap_or(NonZeroU32::MIN));
RateLimiter::dashmap(quota)
}