Skip to main content

Crate culverin

Crate culverin 

Source
Expand description

Culverin - A HTTP load testing library

Culverin is a HTTP load testing tool inspired by Vegeta, designed to be used both as a command-line tool and as a library in other Rust applications.

§Example

use culverin::{AttackBuilder, Target, Header};
use url::Url;
use std::time::Duration;
 
#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Create targets
    let target = Target {
        method: "GET".to_string(),
        url: Url::parse("https://example.com")?,
        headers: vec![
            Header {
                name: "User-Agent".to_string(),
                value: "culverin".to_string(),
            }
        ],
        body: None,
    };
 
    // Run the attack
    let results = AttackBuilder::new()
        .rate(50.0)  // 50 requests per second
        .duration(Duration::from_secs(30))
        .timeout(Duration::from_secs(5))
        .targets(vec![target])
        .run()
        .await?;
 
    // Process results
    println!("Attack completed with {} results", results.len());
     
    Ok(())
}

Structs§

AttackBuilder
Builder for configuring and running an attack
AttackConfig
Represents attack parameters
AttackResult
Represents the result of a single request
Header
Represents an HTTP header
Metrics
Represents metrics from a load test
Target
Represents a target for the load test

Functions§

calculate_metrics
Calculate metrics from attack results
get
Helper function to create a GET target
post
Helper function to create a POST target
target
Helper function to create a target with common defaults