| Crates.io | limiteron |
| lib.rs | limiteron |
| version | 0.1.1 |
| created_at | 2026-01-19 09:15:06.962554+00 |
| updated_at | 2026-01-19 09:21:38.811469+00 |
| description | Unified flow control framework for Rust |
| homepage | |
| repository | https://github.com/Kirky-X/limiteron |
| max_upload_size | |
| id | 2054062 |
| size | 1,436,831 |
Rust Unified Flow Control Framework
Features โข Quick Start โข Documentation โข Examples โข Contributing
๐ฏ Core Features
|
โก Advanced Features
|
graph LR
A[่ฏทๆฑ] --> B[ๆ ่ฏ็ฌฆๆๅ]
B --> C[้ๆตๆฃๆฅ]
B --> D[ๅฐ็ฆๆฃๆฅ]
B --> E[้
้ขๆฃๆฅ]
C --> F[ๅณ็ญ้พ]
D --> F
E --> F
F --> G[ๅ
่ฎธ/ๆ็ป]
style A fill:#e1f5ff
style B fill:#b3e5fc
style C fill:#81d4fa
style D fill:#81d4fa
style E fill:#81d4fa
style F fill:#4fc3f7
style G fill:#29b6f6
use limiteron::limiters::{Limiter, TokenBucketLimiter};
async fn enterprise_api() -> Result<(), Box<dyn std::error::Error>> {
let limiter = TokenBucketLimiter::new(100, 10); // 100 tokens, refill 10 per second
// Rate limiting check
match limiter.allow(1).await {
Ok(true) => {
// Process request
process_request().await;
}
Ok(false) => {
eprintln!("Rate limit exceeded");
}
Err(e) => {
eprintln!("Error: {:?}", e);
}
}
Ok(())
}
async fn process_request() {
println!("Processing request...");
}
Suitable for enterprise applications requiring high concurrency and reliability.
use limiteron::flow_control;
#[flow_control(rate = "100/s", quota = "10000/m", concurrency = 50)]
async fn api_handler(user_id: &str) -> Result<String, limiteron::error::FlowGuardError> {
// API business logic
Ok("Success".to_string())
}
Suitable for protecting API services from abuse and DDoS attacks.
use limiteron::ban_manager::{BanManager, BanTarget};
use limiteron::storage::MockBanStorage;
use std::sync::Arc;
async fn web_app() -> Result<(), Box<dyn std::error::Error>> {
// Create storage and ban manager
let storage = Arc::new(MockBanStorage::default());
let ban_manager = BanManager::new(storage, None).await?;
// Check if user is banned
let user_target = BanTarget::UserId("user123".to_string());
if let Some(ban_record) = ban_manager.is_banned(&user_target).await? {
println!("User is banned: {:?}", ban_record);
return Err("User is banned".into());
}
// Process request
println!("Processing request for user123");
Ok(())
}
Suitable for web applications that need to prevent malicious users and crawlers.
๐ฆ Cargo
|
๐ง Features
|
Limiteron ไฝฟ็จ feature flags ๆฅๆงๅถๅ่ฝๅฏ็จ๏ผ้ป่ฎคๅชๅฏ็จๅ ๅญๅญๅจ๏ผ
|
้ขๅฎไน็ปๅ
|
ๅ็ฌ็นๆง
|
| ็นๆง | ๆ่ฟฐ | ้ป่ฎค |
|---|---|---|
memory |
ๅ ๅญๅญๅจ | โ |
postgres |
PostgreSQL ๅญๅจ | โ |
redis |
Redis ๅญๅจ | โ |
ban-manager |
ๅฐ็ฆ็ฎก็ | โ |
quota-control |
้ ้ขๆงๅถ | โ |
circuit-breaker |
็ๆญๅจ | โ |
macros |
ๅฎๆฏๆ | โ |
telemetry |
้ฅๆตๅ่ฟฝ่ธช | โ |
monitoring |
Prometheus ๆๆ | โ |
|
Step 1: Add Dependency
|
Step 2: Use Macro
|
use limiteron::limiters::{Limiter, TokenBucketLimiter};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Step 1: Create limiter
let limiter = TokenBucketLimiter::new(10, 1); // 10 tokens, refill 1 per second
// Step 2: Check rate limit
match limiter.allow(1).await {
Ok(true) => println!("โ
Request allowed"),
Ok(false) => println!("โ Request rate limited"),
Err(e) => println!("โ Error: {:?}", e),
}
// Step 3: Use with cost
match limiter.allow(2).await {
Ok(true) => println!("โ
Request with cost 2 allowed"),
Ok(false) => println!("โ Request with cost 2 rate limited"),
Err(e) => println!("โ Error: {:?}", e),
}
Ok(())
}
|
User Guide Complete usage guide |
API Reference Complete API documentation |
FAQ Frequently asked questions |
Examples Code examples |
๐ Example 1: Basic Rate Limiting
View Output
|
๐ฅ Example 2: Using Macro
View Output
|
graph TB
A[User App] --> B[API Layer]
B --> C[Governor]
C --> D[Identifier Extraction]
C --> E[Decision Chain]
D --> F[Matchers]
E --> G[Limiters]
E --> H[Ban Management]
E --> I[Quota Control]
E --> J[Circuit Breaker]
G --> K[L2/L3 Cache]
H --> K
I --> K
K --> L[Storage Layer]
L --> M[PostgreSQL]
L --> N[Redis]
L --> O[Memory]
style A fill:#e1f5ff
style B fill:#b3e5fc
style C fill:#81d4fa
style D fill:#4fc3f7
style E fill:#4fc3f7
style F fill:#29b6f6
style G fill:#29b6f6
style H fill:#29b6f6
style I fill:#29b6f6
style J fill:#29b6f6
style K fill:#0288d1
style L fill:#0277bd
style M fill:#01579b
style N fill:#01579b
style O fill:#01579b
| Component | Description | Status |
|---|---|---|
| Governor | Main controller, end-to-end flow control | โ Stable |
| Matchers | Identifier extraction (IP, User ID, Device ID, etc.) | โ Stable |
| Limiters | Multiple rate limiting algorithms | โ Stable |
| Ban Management | IP ban, automatic ban | โ Stable |
| Quota Control | Quota allocation, quota alerts | โ Stable |
| Circuit Breaker | Automatic failover, state recovery | โ Stable |
| Cache | L2/L3 cache support | โ Stable |
| Storage Layer | PostgreSQL, Redis, in-memory | โ Stable |
|
Basic Configuration
|
Advanced Configuration
|
| Option | Type | Default | Description |
|---|---|---|---|
rate_limit |
String | "100/s" | Rate limit |
quota_limit |
String | "10000/m" | Quota limit |
concurrency_limit |
Integer | 50 | Concurrency limit |
l2_capacity |
Integer | 10000 | L2 cache capacity |
l3_capacity |
Integer | 100000 | L3 cache capacity |
storage_type |
String | "memory" | Storage type |
enable_metrics |
Boolean | false | Enable metrics |
enable_tracing |
Boolean | false | Enable tracing |
# Run all tests
cargo test --all-features
# Run specific test
cargo test test_name
# Run integration tests
cargo test --test integration_tests
# Run benchmarks
cargo bench
Note: The following data represents actual benchmark results from comprehensive testing (2026-01-19).
|
Throughput
|
Latency
|
| Test Item | Result | Status |
|---|---|---|
| Data Consistency | 100% | โ Pass |
| High Concurrency Stability | 50/100 concurrent | โ Pass |
| Rate Limit Correctness | 1000/1000 | โ Pass |
# Run performance tests
cd temp/comprehensive_test
./target/release/functional_test # Functional tests
./target/release/performance_test # Performance tests
./target/release/concurrency_test # Concurrency tests
Sample output:
ๅ่ฝๆต่ฏ: 7/7 Pass (100%)
TokenBucket: 12,088,759 ops/s
FixedWindow: 19,920,188 ops/s
ConcurrencyLimiter: 11,891,237 ops/s
ๅนถๅๆต่ฏ: 100% ๆฐๆฎไธ่ดๆง
|
Memory Safety Rust guarantees memory safety |
Input Validation Comprehensive input checking |
SQL Injection Protection Parameterized queries |
Password Protection Secure password storage |
Please report security vulnerabilities through GitHub Issues.
gantt
title Limiteron Roadmap
dateFormat YYYY-MM
section Phase 1
Core Features :done, 2026-01, 2026-03
section Phase 2
Feature Extensions :active, 2026-03, 2026-06
section Phase 3
Performance Optimization :2026-06, 2026-09
section Phase 4
Production Ready :2026-09, 2026-12
โ Completed
|
๐ง In Progress
|
๐ Planned
|
๐ก Future Ideas
|
๐ Report IssuesFound a bug? |
๐ก Feature RequestsHave a suggestion? |
๐ง Submit CodeWant to contribute? |
git clone https://github.com/yourusername/limiteron.gitgit checkout -b feature/amazing-featurecargo test --all-featuresgit commit -m 'Add amazing feature'git push origin feature/amazing-feature|
Rust |
![]() GitHub |
Open Source |
Community |
๐ Dependencies - Built on these excellent projects:
๐ฅ Contributors - Thanks to all contributors!
๐ฌ Community - Special thanks to community members
|
Issues Report bugs and errors |
Discussions Ask questions and share ideas |
GitHub View source code |
If you find this project useful, please consider giving it a โญ๏ธ!
Built with โค๏ธ by Kirky.X
ยฉ 2026 Kirky.X. All rights reserved.