pub mod auth;
pub mod config;
pub mod guards;
pub mod rate_limit_backend;
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::{
BackendErrorPolicy, BackpressureConfig, ChannelCacheConfig, ChannelConfig,
ChannelRateLimitConfig, DeduplicationConfig,
};
pub use rate_limit_backend::{LocalRateLimitBackend, RateLimitBackend, RedisRateLimitBackend};
pub use registry::{ChannelLoadIssue, ChannelRegistry, ChannelRuntimeConfig, ClusterBackends};
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)
}