simple-concurrent-get

Crates.iosimple-concurrent-get
lib.rssimple-concurrent-get
version
sourcesrc
created_at2024-11-18 07:13:17.936677
updated_at2024-11-25 10:34:55.076974
descriptionSimply make multiple concurrent HTTP GET requests
homepagehttps://github.com/ParkSnoopy/simple-concurrent-get
repositoryhttps://github.com/ParkSnoopy/simple-concurrent-get
max_upload_size
id1451888
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(ParkSnoopy)

documentation

https://docs.rs/simple-concurrent-get

README

simple-concurrent-get

Latest version Documentation MIT

Make multiple concurrent HTTP GET requests with ease.

Usage

  • concurrent_get
#[tokio::main]
async fn main() {
    let request_urls = vec![
        "https://example.com/1",
        "https://example.com/2",
        "https://example.com/3",
        "https://example.com/4",
        // ...
    ];

    // for example: maximum 3 concurrent request
    let request_results = simple_concurrent_get::concurrent_get(request_urls, 3);
    let _: Vec<_> = request_results
        .await
        .map(|result| match result {
            Ok(response) => {
                let url = response.url().to_owned();
                let bytes = futures_executor::block_on(async{ response.bytes().await }).unwrap();
                println!("Successfully got '{}' with '{}' bytes of content", url, bytes.len())
            },
            Err(e) => eprintln!("{}", e),
        })
        .collect();
}
  • concurrent_get_foreach
#[tokio::main]
async fn main() {
    let request_urls = vec![
        "https://example.com/1",
        "https://example.com/2",
        "https://example.com/3",
        "https://example.com/4",
        // ...
    ];

    // for example: maximum 3 concurrent request
    let _: Vec<_> = simple_concurrent_get::concurrent_get_foreach(request_urls, 3,
        |result| match result {
            Ok(response) => {
                let url = response.url().to_owned();
                let bytes = futures_executor::block_on(async{ response.bytes().await }).unwrap();
                println!("Successfully got '{}' with '{}' bytes of content", url, bytes.len())
            },
            Err(e) => eprintln!("{}", e),
        }
    )
        .await
        .collect(); 
}
Commit count: 25

cargo fmt