From d0646dee25b6e8db330dd61ac01175a789ba8b09 Mon Sep 17 00:00:00 2001 From: asonix Date: Wed, 20 Sep 2023 19:22:49 -0500 Subject: [PATCH] Add config option for external validation timeout --- defaults.toml | 1 + src/config/commandline.rs | 8 ++++++++ src/config/defaults.rs | 2 ++ src/config/file.rs | 2 ++ 4 files changed, 13 insertions(+) diff --git a/defaults.toml b/defaults.toml index 1e1e49b..3b2ad71 100644 --- a/defaults.toml +++ b/defaults.toml @@ -26,6 +26,7 @@ cache_capacity = 67108864 export_path = "/mnt/exports" [media] +external_validation_timeout = 30 max_file_size = 40 process_timeout = 30 filters = [ diff --git a/src/config/commandline.rs b/src/config/commandline.rs index dd1754e..310bab2 100644 --- a/src/config/commandline.rs +++ b/src/config/commandline.rs @@ -57,6 +57,7 @@ impl Args { metrics_prometheus_address, media_preprocess_steps, media_external_validation, + media_external_validation_timeout, media_max_file_size, media_process_timeout, media_retention_variants, @@ -185,6 +186,7 @@ impl Args { process_timeout: media_process_timeout, preprocess_steps: media_preprocess_steps, external_validation: media_external_validation, + external_validation_timeout: media_external_validation_timeout, filters: media_filters, retention: retention.set(), image: image.set(), @@ -553,6 +555,8 @@ struct Media { #[serde(skip_serializing_if = "Option::is_none")] external_validation: Option, #[serde(skip_serializing_if = "Option::is_none")] + external_validation_timeout: Option, + #[serde(skip_serializing_if = "Option::is_none")] filters: Option>, #[serde(skip_serializing_if = "Option::is_none")] retention: Option, @@ -892,6 +896,10 @@ struct Run { #[arg(long)] media_external_validation: Option, + /// Timeout for requests to the external validation endpoint + #[arg(long)] + media_external_validation_timeout: Option, + /// Which media filters should be enabled on the `process` endpoint #[arg(long)] media_filters: Option>, diff --git a/src/config/defaults.rs b/src/config/defaults.rs index 935d5c9..bec933b 100644 --- a/src/config/defaults.rs +++ b/src/config/defaults.rs @@ -64,6 +64,7 @@ struct OpenTelemetryDefaults { #[derive(Clone, Debug, serde::Serialize)] #[serde(rename_all = "snake_case")] struct MediaDefaults { + external_validation_timeout: u64, max_file_size: usize, process_timeout: u64, filters: Vec, @@ -220,6 +221,7 @@ impl Default for OpenTelemetryDefaults { impl Default for MediaDefaults { fn default() -> Self { MediaDefaults { + external_validation_timeout: 30, max_file_size: 40, process_timeout: 30, filters: vec![ diff --git a/src/config/file.rs b/src/config/file.rs index 26da6f3..df35c5a 100644 --- a/src/config/file.rs +++ b/src/config/file.rs @@ -167,6 +167,8 @@ pub(crate) struct OldDb { pub(crate) struct Media { pub(crate) external_validation: Option, + pub(crate) external_validation_timeout: u64, + pub(crate) max_file_size: usize, pub(crate) process_timeout: u64,