Commit f3bbc6ad9f
Unregistered key
Layout: unified · split
src/config.rs +6
| @@ -25,6 +25,8 @@ macro_rules! usage { | ||
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | const DEFAULT_REQ_TIMEOUT: u64 = 120; | |
| 29 | ||
| 28 | 30 | const COLORS: [Color; 13] = [ |
| 29 | 31 | Color::Blue, |
| 30 | 32 | Color::Cyan, |
| @@ -182,6 +184,7 @@ pub struct TunableValues { | ||
| 182 | 184 | pub reaction_shortcode_display: bool, |
| 183 | 185 | pub read_receipt_send: bool, |
| 184 | 186 | pub read_receipt_display: bool, |
| 187 | pub request_timeout: u64, | |
| 185 | 188 | pub typing_notice_send: bool, |
| 186 | 189 | pub typing_notice_display: bool, |
| 187 | 190 | pub users: UserOverrides, |
| @@ -194,6 +197,7 @@ pub struct Tunables { | ||
| 194 | 197 | pub reaction_shortcode_display: Option<bool>, |
| 195 | 198 | pub read_receipt_send: Option<bool>, |
| 196 | 199 | pub read_receipt_display: Option<bool>, |
| 200 | pub request_timeout: Option<u64>, | |
| 197 | 201 | pub typing_notice_send: Option<bool>, |
| 198 | 202 | pub typing_notice_display: Option<bool>, |
| 199 | 203 | pub users: Option<UserOverrides>, |
| @@ -209,6 +213,7 @@ impl Tunables { | ||
| 209 | 213 | .or(other.reaction_shortcode_display), |
| 210 | 214 | read_receipt_send: self.read_receipt_send.or(other.read_receipt_send), |
| 211 | 215 | read_receipt_display: self.read_receipt_display.or(other.read_receipt_display), |
| 216 | request_timeout: self.request_timeout.or(other.request_timeout), | |
| 212 | 217 | typing_notice_send: self.typing_notice_send.or(other.typing_notice_send), |
| 213 | 218 | typing_notice_display: self.typing_notice_display.or(other.typing_notice_display), |
| 214 | 219 | users: merge_users(self.users, other.users), |
| @@ -222,6 +227,7 @@ impl Tunables { | ||
| 222 | 227 | reaction_shortcode_display: self.reaction_shortcode_display.unwrap_or(false), |
| 223 | 228 | read_receipt_send: self.read_receipt_send.unwrap_or(true), |
| 224 | 229 | read_receipt_display: self.read_receipt_display.unwrap_or(true), |
| 230 | request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT), | |
| 225 | 231 | typing_notice_send: self.typing_notice_send.unwrap_or(true), |
| 226 | 232 | typing_notice_display: self.typing_notice_display.unwrap_or(true), |
| 227 | 233 | users: self.users.unwrap_or_default(), |
src/tests.rs +1
| @@ -174,6 +174,7 @@ pub fn mock_tunables() -> TunableValues { | ||
| 174 | 174 | reaction_shortcode_display: false, |
| 175 | 175 | read_receipt_send: true, |
| 176 | 176 | read_receipt_display: true, |
| 177 | request_timeout: 120, | |
| 177 | 178 | typing_notice_send: true, |
| 178 | 179 | typing_notice_display: true, |
| 179 | 180 | users: vec![(TEST_USER5.clone(), UserDisplayTunables { |
src/worker.rs +7 −8
| @@ -82,7 +82,6 @@ use crate::{ | ||
| 82 | 82 | |
| 83 | 83 | const IAMB_DEVICE_NAME: &str = "iamb"; |
| 84 | 84 | const IAMB_USER_AGENT: &str = "iamb"; |
| 85 | const REQ_TIMEOUT: Duration = Duration::from_secs(60); | |
| 86 | 85 | |
| 87 | 86 | fn initial_devname() -> String { |
| 88 | 87 | format!("{} on {}", IAMB_DEVICE_NAME, gethostname().to_string_lossy()) |
| @@ -447,20 +446,20 @@ impl ClientWorker { | ||
| 447 | 446 | let (tx, rx) = unbounded_channel(); |
| 448 | 447 | let account = &settings.profile; |
| 449 | 448 | |
| 450 | // Set up a custom client that only uses HTTP/1. | |
| 451 | // | |
| 452 | // During my testing, I kept stumbling across something weird with sync and HTTP/2 that | |
| 453 | // will need to be revisited in the future. | |
| 449 | let req_timeout = Duration::from_secs(settings.tunables.request_timeout); | |
| 450 | ||
| 451 | // Set up the HTTP client. | |
| 454 | 452 | let http = reqwest::Client::builder() |
| 455 | 453 | .user_agent(IAMB_USER_AGENT) |
| 456 | .timeout(Duration::from_secs(30)) | |
| 454 | .timeout(req_timeout) | |
| 457 | 455 | .pool_idle_timeout(Duration::from_secs(60)) |
| 458 | 456 | .pool_max_idle_per_host(10) |
| 459 | 457 | .tcp_keepalive(Duration::from_secs(10)) |
| 460 | .http1_only() | |
| 461 | 458 | .build() |
| 462 | 459 | .unwrap(); |
| 463 | 460 | |
| 461 | let req_config = RequestConfig::new().timeout(req_timeout).retry_timeout(req_timeout); | |
| 462 | ||
| 464 | 463 | // Set up the Matrix client for the selected profile. |
| 465 | 464 | let client = Client::builder() |
| 466 | 465 | .http_client(Arc::new(http)) |
| @@ -468,7 +467,7 @@ impl ClientWorker { | ||
| 468 | 467 | .store_config(StoreConfig::default()) |
| 469 | 468 | .sled_store(settings.matrix_dir.as_path(), None) |
| 470 | 469 | .expect("Failed to setup up sled store for Matrix SDK") |
| 471 | .request_config(RequestConfig::new().timeout(REQ_TIMEOUT).retry_timeout(REQ_TIMEOUT)) | |
| 470 | .request_config(req_config) | |
| 472 | 471 | .build() |
| 473 | 472 | .await |
| 474 | 473 | .expect("Failed to instantiate Matrix client"); |