Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add arg page_request_timeout_secs #288

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ RestAPI client:
| `wait_time_secs` | Request wait time for page, default to `1` |
| `max_rows_in_buffer` | Max rows for page buffer |
| `max_rows_per_page` | Max response rows for a single page |
| `page_request_timeout_secs` | Timeout for a single page request, default to `30` |

Example to disable presign using set
```
Expand Down
11 changes: 11 additions & 0 deletions core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use std::collections::BTreeMap;
use std::sync::Arc;
use std::time::Duration;

use http::StatusCode;
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -63,6 +64,8 @@ pub struct APIClient {
max_rows_in_buffer: Option<i64>,
max_rows_per_page: Option<i64>,

page_request_timeout: Duration,

tls_ca_file: Option<String>,

presigned_url_disabled: bool,
Expand Down Expand Up @@ -97,6 +100,12 @@ impl APIClient {
"max_rows_per_page" => {
client.max_rows_per_page = Some(v.parse()?);
}
"page_request_timeout_secs" => {
client.page_request_timeout = {
let secs: u64 = v.parse()?;
Duration::from_secs(secs)
};
}
"presigned_url_disabled" => {
client.presigned_url_disabled = match v.as_ref() {
"true" | "1" => true,
Expand Down Expand Up @@ -252,6 +261,7 @@ impl APIClient {
.get(endpoint.clone())
.basic_auth(self.user.clone(), self.password.clone())
.headers(headers.clone())
.timeout(self.page_request_timeout)
.send()
.await
};
Expand Down Expand Up @@ -522,6 +532,7 @@ impl Default for APIClient {
wait_time_secs: None,
max_rows_in_buffer: None,
max_rows_per_page: None,
page_request_timeout: Duration::from_secs(30),
tls_ca_file: None,
presigned_url_disabled: false,
}
Expand Down