Skip to content

Commit

Permalink
feat(s3): make endpoint-style configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
nickamzol committed Jun 27, 2024
1 parent 48babbc commit da34254
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
15 changes: 12 additions & 3 deletions docs/topics/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
<deflist>
Expand All @@ -242,6 +243,14 @@ aets:
The maximum allowed amount of concurrent S3 operations.
Increasing the amount of concurrency will massively improve throughput.
</def>
<def title="endpoint-style" id="s3.endpoint-style">
Sets the URL access style. Defaults to <b>vhost</b>.
Allowed values are:
<list>
<li><b>path</b>: For the deprecated <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#path-style-access">path-style</a>.</li>
<li><b>vhost</b>: For the <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#virtual-hosted-style-access">virtual-hosted-style</a>.</li>
</list>
</def>
</deflist>
## DIMSE Backend Config
Expand Down
4 changes: 2 additions & 2 deletions src/backend/s3/wado.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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.
Expand Down
19 changes: 17 additions & 2 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,28 @@ pub struct S3Config {
pub concurrency: usize,
#[serde(default)]
pub credentials: Option<S3Credentials>,
#[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)]
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit da34254

Please sign in to comment.