Skip to content

Commit 8d2c09e

Browse files
committed
make AWS SDK retries configurable, add more retries to creating CDN invalidations
1 parent 33e304f commit 8d2c09e

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/cdn.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ impl CdnBackend {
3535
CdnKind::CloudFront => {
3636
let shared_config = runtime.block_on(aws_config::load_from_env());
3737
let config_builder = aws_sdk_cloudfront::config::Builder::from(&shared_config)
38-
.retry_config(RetryConfig::standard().with_max_attempts(3))
38+
.retry_config(
39+
RetryConfig::standard().with_max_attempts(config.aws_sdk_max_retries),
40+
)
3941
.region(Region::new(config.s3_region.clone()));
4042

4143
Self::CloudFront {

src/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ pub struct Config {
2020
// Storage params
2121
pub(crate) storage_backend: StorageKind,
2222

23+
// AWS SDK configuration
24+
pub(crate) aws_sdk_max_retries: u32,
25+
2326
// S3 params
2427
pub(crate) s3_bucket: String,
2528
pub(crate) s3_region: String,
@@ -123,6 +126,8 @@ impl Config {
123126

124127
storage_backend: env("DOCSRS_STORAGE_BACKEND", StorageKind::Database)?,
125128

129+
aws_sdk_max_retries: env("DOCSRS_AWS_SDK_MAX_RETRIES", 6)?,
130+
126131
s3_bucket: env("DOCSRS_S3_BUCKET", "rust-docs-rs".to_string())?,
127132
s3_region: env("S3_REGION", "us-west-1".to_string())?,
128133
s3_endpoint: maybe_env("S3_ENDPOINT")?,

src/storage/s3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl S3Backend {
3737
) -> Result<Self, Error> {
3838
let shared_config = runtime.block_on(aws_config::load_from_env());
3939
let mut config_builder = aws_sdk_s3::config::Builder::from(&shared_config)
40-
.retry_config(RetryConfig::standard().with_max_attempts(6))
40+
.retry_config(RetryConfig::standard().with_max_attempts(config.aws_sdk_max_retries))
4141
.region(Region::new(config.s3_region.clone()));
4242

4343
if let Some(ref endpoint) = config.s3_endpoint {

0 commit comments

Comments
 (0)