mirror of
https://github.com/Noratrieb/ice-104649.git
synced 2026-01-14 12:35:02 +01:00
no async
This commit is contained in:
parent
206a6628ea
commit
9d73254291
1 changed files with 12 additions and 27 deletions
29
src/main.rs
29
src/main.rs
|
|
@ -1,20 +1,11 @@
|
|||
use futures::{stream, StreamExt};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
const REQUEST_COUNT: usize = 10;
|
||||
const CONCURRENT_REQUESTS: usize = 1_000;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Error> {
|
||||
let client = reqwest::Client::builder()
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
let urls = vec![String::from("http://example.com")];
|
||||
fn main() {
|
||||
let client = reqwest::Client::builder().build().unwrap();
|
||||
|
||||
// Concurrent Requests
|
||||
let bodies = stream::iter(urls)
|
||||
.map(|url| {
|
||||
let bodies = stream::iter([])
|
||||
.map(|url: String| {
|
||||
let req = client.get(&url);
|
||||
tokio::spawn(async move {
|
||||
let resp = req.send().await.unwrap();
|
||||
|
|
@ -22,19 +13,13 @@ async fn main() -> Result<(), Error> {
|
|||
Result::Ok((url, text))
|
||||
})
|
||||
})
|
||||
.buffer_unordered(CONCURRENT_REQUESTS);
|
||||
.buffer_unordered(0);
|
||||
|
||||
bodies
|
||||
.for_each(|b| async {
|
||||
bodies.for_each(|b| async {
|
||||
match b {
|
||||
Ok(Ok((url, b))) => {}
|
||||
Err(e) => {}
|
||||
Ok(Err(e)) => {}
|
||||
}
|
||||
})
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
struct Error;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue