limit-lens Rust Client
A Rust client library for interacting with the limit-lens API - a service for testing and visualizing rate limiters in real-time.
Installation
cargo add limit-lens
Usage
This client provides access to the following API endpoints:
- Health API: Check service health status
- Rate Test API: Create test sessions, get metrics, and simulate requests
Example
use limit_lens::apis::{configuration::Configuration, rate_test_api, health_api};
use limit_lens::models::CreateSessionRequest;
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = Configuration::default();
let health = health_api::health_check(&config).await?;
println!("API Health: {}", health);
let session_request = CreateSessionRequest::new();
let session = rate_test_api::create_test_session(&config, session_request).await?;
println!("Created session with ID: {}", session.id);
for _ in 0..10 {
let response = rate_test_api::receive_test_request(&config, &session.id).await?;
println!("Request status: {}", response.status());
}
let metrics = rate_test_api::get_test_metrics(&config, &session.id).await?;
println!("Total requests: {}", metrics.total_requests);
println!("Requests per second: {}", metrics.requests_per_second);
for bucket in metrics.request_distribution {
println!("Time: {}, Count: {}", bucket.timestamp, bucket.count);
}
Ok(())
}
Documentation
The library consists of two main modules:
apis: Contains client methods for calling API endpoints
models: Contains data structures used by the API
For detailed documentation:
cargo doc --open
License
This project is licensed under the MIT License - see the LICENSE file for details.