gatekpr-rate-limiter 0.2.3

Reusable rate limiting with multiple backend support
Documentation
//! Reusable rate limiting library
//!
//! Provides a flexible, high-performance rate limiting solution with:
//! - Lock-free concurrent access using DashMap
//! - Configurable per-minute and per-hour limits
//! - Plan-based configuration (free, pro, enterprise)
//! - Optional Axum middleware integration
//!
//! # Basic Usage
//!
//! ```rust
//! use gatekpr_rate_limiter::{RateLimitConfig, RateLimitStore};
//!
//! // Create a store to track rate limits
//! let store = RateLimitStore::new();
//!
//! // Get config for a plan
//! let config = RateLimitConfig::for_plan("pro");
//!
//! // Check rate limit for a key (e.g., user ID, IP, tenant)
//! let result = store.check("user-123", &config);
//!
//! if result.is_allowed() {
//!     // Process the request
//! } else {
//!     // Return 429 Too Many Requests
//!     if let Some(retry_after) = result.retry_after() {
//!         println!("Rate limited. Retry after {} seconds", retry_after);
//!     }
//! }
//! ```
//!
//! # Custom Configuration
//!
//! ```rust
//! use gatekpr_rate_limiter::RateLimitConfigBuilder;
//!
//! let config = RateLimitConfigBuilder::new()
//!     .per_minute(200)
//!     .per_hour(10000)
//!     .build();
//! ```
//!
//! # Axum Integration (requires `axum` feature)
//!
//! ```rust,ignore
//! use gatekpr_rate_limiter::axum::RateLimitLayer;
//! use axum::Router;
//!
//! let app = Router::new()
//!     .route("/api", get(handler))
//!     .layer(RateLimitLayer::new());
//! ```

pub mod config;
pub mod state;

#[cfg(feature = "axum")]
pub mod axum_layer;

// Re-exports
pub use config::{RateLimitConfig, RateLimitConfigBuilder};
pub use state::{KeyRateLimit, RateLimitResult, RateLimitStore};

#[cfg(feature = "axum")]
pub use axum_layer::{RateLimitLayer, RateLimitService};

/// Prelude module for convenient imports
pub mod prelude {
    pub use crate::config::{RateLimitConfig, RateLimitConfigBuilder};
    pub use crate::state::{RateLimitResult, RateLimitStore};

    #[cfg(feature = "axum")]
    pub use crate::axum_layer::{RateLimitLayer, RateLimitService};
}