simple_concurrent_get/lib.rs
1//! # simple-concurrent-get
2//!
3//! Make multiple concurrent HTTP GET requests with ease.
4//!
5//! ## Making a GET request
6//!
7//! using `concurrent_get`
8//! ```rust
9//! #[tokio::main]
10//! async fn main() {
11//! let request_urls = vec![
12//! "https://example.com/1",
13//! "https://example.com/2",
14//! "https://example.com/3",
15//! "https://example.com/4",
16//! // ...
17//! ];
18//!
19//! // for example: maximum 3 concurrent request
20//! let _: Vec<_> = simple_concurrent_get::concurrent_get(request_urls, 3)
21//! .await
22//! .map(|result| match result {
23//! Ok(response) => {
24//! let url = response.url().to_owned();
25//! let bytes = futures_executor::block_on(async{ response.bytes().await }).unwrap();
26//! println!("Successfully got '{}' with '{}' bytes of content", url, bytes.len())
27//! },
28//! Err(e) => eprintln!("{}", e),
29//! })
30//! .collect();
31//! }
32//! ```
33//!
34//! using `concurrent_get_foreach`
35//! ( which is simply passing process function as argument )
36//! ``` rust
37//! #[tokio::main]
38//! async fn main() {
39//! let request_urls = vec![
40//! "https://example.com/1",
41//! "https://example.com/2",
42//! "https://example.com/3",
43//! "https://example.com/4",
44//! // ...
45//! ];
46//!
47//! // for example: maximum 3 concurrent request
48//! // ensure response is in order
49//! let _: Vec<_> = simple_concurrent_get::ordered::concurrent_get_foreach(request_urls, 3,
50//! |result| match result {
51//! Ok(response) => {
52//! let url = response.url().to_owned();
53//! let bytes = futures_executor::block_on(async{ response.bytes().await }).unwrap();
54//! println!("Successfully got '{}' with '{}' bytes of content", url, bytes.len())
55//! },
56//! Err(e) => eprintln!("{}", e),
57//! }
58//! )
59//! .await
60//! .collect();
61//!}
62//!```
63//!
64
65
66
67mod config;
68mod client;
69
70pub mod unordered;
71pub mod ordered;
72
73#[cfg(test)]
74mod tests;
75
76// unordered as default
77pub use unordered::*;