initial commit

This commit is contained in:
Jan Christian Grünhage 2020-08-17 12:33:48 +02:00
commit e26c6d4273
4 changed files with 1126 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1096
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

12
Cargo.toml Normal file
View File

@ -0,0 +1,12 @@
[package]
name = "get_a_thousand_status_codes"
version = "0.1.0"
authors = ["Jan Christian Grünhage <jan.christian@gruenhage.xyz>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
reqwest = "0.10.7"
tokio = { version = "0.2.22", features = ["rt-threaded", "macros"] }
futures-util = "0.3.5"

17
src/main.rs Normal file
View File

@ -0,0 +1,17 @@
#[tokio::main]
async fn main() {
let mut handles = Vec::with_capacity(1000);
for _ in 0..1000 {
handles.push(tokio::spawn(async {
match reqwest::get("http://localhost:2015").await.and_then(|resp| {
Ok(resp.status())
}) {
Ok(status) => println!("{}", status),
Err(_) => eprintln!("Something went wrong here"),
};
}));
}
for handle in handles {
handle.await;
}
}