get_a_thousand_status_codes/src/main.rs
Jan Christian Grünhage e26c6d4273 initial commit
2020-08-17 12:33:48 +02:00

18 lines
489 B
Rust

#[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;
}
}