limit-lens

Crates.iolimit-lens
lib.rslimit-lens
version0.6.1
created_at2025-04-20 11:28:56.163719+00
updated_at2025-04-21 16:45:42.493435+00
descriptionA simple API for testing and visualizing rate limiters in real-time. Monitor request throughput and see how your rate limiting algorithms perform under load.
homepage
repository
max_upload_size
id1641641
size72,995
Akhilesh Sharma (akhileshsharma99)

documentation

README

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.

This client is for limit-lens.

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>> {
    // Set up client configuration
    let config = Configuration::default();
    
    // Check API health
    let health = health_api::health_check(&config).await?;
    println!("API Health: {}", health);
    
    // Create a new test session
    let session_request = CreateSessionRequest::new();
    let session = rate_test_api::create_test_session(&config, session_request).await?;
    println!("Created session with ID: {}", session.id);
    
    // Send test requests
    for _ in 0..10 {
        let response = rate_test_api::receive_test_request(&config, &session.id).await?;
        println!("Request status: {}", response.status());
    }
    
    // Get metrics for the session
    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);
    
    // Print request distribution
    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.

Commit count: 0

cargo fmt