From da34254381a49680aa5651dd034ad775a5809e45 Mon Sep 17 00:00:00 2001 From: Nicolas Kamzol Date: Thu, 27 Jun 2024 14:41:54 +0200 Subject: [PATCH] feat(s3): make endpoint-style configurable --- docs/topics/configuration.md | 15 ++++++++++++--- src/backend/s3/wado.rs | 4 ++-- src/config/mod.rs | 19 +++++++++++++++++-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/docs/topics/configuration.md b/docs/topics/configuration.md index e2b0130..f2fe09e 100644 --- a/docs/topics/configuration.md +++ b/docs/topics/configuration.md @@ -212,13 +212,14 @@ The following options are available if the S3 backend is selected: aets: - aet: RESEARCH backend: S3 - endpoint: http://s3.local + endpoint: http://dicom.s3.local + endpoint-style: vhost bucket: research region: local concurrency: 32 credentials: - access-key: ABC123 - secret-key: topSecret + access-key: ABC123 + secret-key: topSecret ``` @@ -242,6 +243,14 @@ aets: The maximum allowed amount of concurrent S3 operations. Increasing the amount of concurrency will massively improve throughput. + + Sets the URL access style. Defaults to vhost. + Allowed values are: + +
  • path: For the deprecated path-style.
  • +
  • vhost: For the virtual-hosted-style.
  • +
    +
    ## DIMSE Backend Config diff --git a/src/backend/s3/wado.rs b/src/backend/s3/wado.rs index 8613035..1a6a562 100644 --- a/src/backend/s3/wado.rs +++ b/src/backend/s3/wado.rs @@ -1,7 +1,7 @@ use crate::api::wado::{InstanceResponse, RetrieveError, RetrieveInstanceRequest, WadoService}; use crate::backend::dimse::cmove::movescu::MoveError; use crate::backend::dimse::wado::DicomMultipartStream; -use crate::config::{S3Config, S3Credentials}; +use crate::config::{S3Config, S3Credentials, S3EndpointStyle}; use async_trait::async_trait; use aws_config::retry::RetryConfig; use aws_config::stalled_stream_protection::StalledStreamProtectionConfig; @@ -56,7 +56,7 @@ impl S3WadoService { .endpoint_url(&config.endpoint) .region(config.region.clone().map(Region::new)) .behavior_version(BehaviorVersion::latest()) - .force_path_style(true) + .force_path_style(matches!(config.endpoint_style, S3EndpointStyle::Path)) .retry_config(RetryConfig::adaptive()) // Causes issues with long-running requests and high concurrency. // It's okay to stall for some time. diff --git a/src/config/mod.rs b/src/config/mod.rs index 64f97cf..1c5ef14 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -58,13 +58,28 @@ pub struct S3Config { pub concurrency: usize, #[serde(default)] pub credentials: Option, + #[serde(default)] + pub endpoint_style: S3EndpointStyle, +} + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum S3EndpointStyle { + Path, + VHost, +} + +impl Default for S3EndpointStyle { + fn default() -> Self { + Self::VHost + } } #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "kebab-case")] pub struct S3Credentials { pub secret_key: String, - pub access_key: String + pub access_key: String, } #[derive(Debug, Clone, Deserialize)] @@ -170,7 +185,7 @@ pub struct HttpServerConfig { pub port: u16, pub max_upload_size: usize, pub request_timeout: u64, - pub graceful_shutdown: bool + pub graceful_shutdown: bool, } impl Default for HttpServerConfig {