diff options
| author | Ellie Huxtable <ellie@elliehuxtable.com> | 2023-09-18 08:39:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-18 08:39:19 +0100 |
| commit | 351b3e8a57c9e0143b7b6f3ed2160dcdce00225e (patch) | |
| tree | b8d91a569daf2d819eea7a92e977458a3f3394a6 /atuin-client/src/api_client.rs | |
| parent | feat(keyup): Configure SearchMode for KeyUp invocation #1216 (#1224) (diff) | |
| download | atuin-351b3e8a57c9e0143b7b6f3ed2160dcdce00225e.zip | |
Add connect timeout and overall timeout (#1238)
* Add connect timeout and overall timeout
* Make it configurable
* Fix test
* Add docs
Diffstat (limited to 'atuin-client/src/api_client.rs')
| -rw-r--r-- | atuin-client/src/api_client.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/atuin-client/src/api_client.rs b/atuin-client/src/api_client.rs index d2ca339f..b6625a34 100644 --- a/atuin-client/src/api_client.rs +++ b/atuin-client/src/api_client.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; use std::env; +use std::time::Duration; use eyre::{bail, Result}; use reqwest::{ @@ -106,7 +107,12 @@ pub async fn latest_version() -> Result<Version> { } impl<'a> Client<'a> { - pub fn new(sync_addr: &'a str, session_token: &'a str) -> Result<Self> { + pub fn new( + sync_addr: &'a str, + session_token: &'a str, + connect_timeout: u64, + timeout: u64, + ) -> Result<Self> { let mut headers = HeaderMap::new(); headers.insert(AUTHORIZATION, format!("Token {session_token}").parse()?); @@ -115,6 +121,8 @@ impl<'a> Client<'a> { client: reqwest::Client::builder() .user_agent(APP_USER_AGENT) .default_headers(headers) + .connect_timeout(Duration::new(connect_timeout, 0)) + .timeout(Duration::new(timeout, 0)) .build()?, }) } |
