1use std::sync::OnceLock;
2use std::time::Duration;
3
4fn build(timeout: Option<Duration>) -> reqwest::Client {
5 let mut builder = reqwest::Client::builder();
6 if let Some(timeout) = timeout {
7 builder = builder.timeout(timeout);
8 }
9 builder.build().unwrap_or_else(|_| reqwest::Client::new())
10}
11
12pub fn shared() -> reqwest::Client {
14 static CLIENT: OnceLock<reqwest::Client> = OnceLock::new();
15 CLIENT.get_or_init(|| build(None)).clone()
16}
17
18pub fn standard() -> reqwest::Client {
20 static CLIENT: OnceLock<reqwest::Client> = OnceLock::new();
21 CLIENT
22 .get_or_init(|| build(Some(Duration::from_secs(30))))
23 .clone()
24}
25
26pub fn long() -> reqwest::Client {
28 static CLIENT: OnceLock<reqwest::Client> = OnceLock::new();
29 CLIENT
30 .get_or_init(|| build(Some(Duration::from_secs(120))))
31 .clone()
32}