|
1 | 1 | use crate::{cdn::CdnKind, storage::StorageKind}; |
2 | 2 | use anyhow::{anyhow, bail, Context, Result}; |
3 | | -use std::env::VarError; |
4 | | -use std::error::Error; |
5 | | -use std::path::PathBuf; |
6 | | -use std::str::FromStr; |
| 3 | +use std::{env::VarError, error::Error, path::PathBuf, str::FromStr, time::Duration}; |
7 | 4 | use tracing::trace; |
8 | 5 |
|
9 | 6 | #[derive(Debug)] |
@@ -42,7 +39,7 @@ pub struct Config { |
42 | 39 | pub(crate) gitlab_accesstoken: Option<String>, |
43 | 40 |
|
44 | 41 | // request timeout in seconds |
45 | | - pub(crate) request_timeout: Option<u64>, |
| 42 | + pub(crate) request_timeout: Option<Duration>, |
46 | 43 | pub(crate) report_request_timeouts: bool, |
47 | 44 |
|
48 | 45 | // Max size of the files served by the docs.rs frontend |
@@ -161,7 +158,7 @@ impl Config { |
161 | 158 | max_parse_memory: env("DOCSRS_MAX_PARSE_MEMORY", 5 * 1024 * 1024)?, |
162 | 159 | registry_gc_interval: env("DOCSRS_REGISTRY_GC_INTERVAL", 60 * 60)?, |
163 | 160 | render_threads: env("DOCSRS_RENDER_THREADS", num_cpus::get())?, |
164 | | - request_timeout: maybe_env("DOCSRS_REQUEST_TIMEOUT")?, |
| 161 | + request_timeout: maybe_env::<u64>("DOCSRS_REQUEST_TIMEOUT")?.map(Duration::from_secs), |
165 | 162 | report_request_timeouts: env("DOCSRS_REPORT_REQUEST_TIMEOUTS", false)?, |
166 | 163 |
|
167 | 164 | random_crate_search_view_size: env("DOCSRS_RANDOM_CRATE_SEARCH_VIEW_SIZE", 500)?, |
|
0 commit comments