-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into jbe/delete_release_workflow
- Loading branch information
Showing
343 changed files
with
133,244 additions
and
43,323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.20.0 | ||
0.22.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import class Foundation.ProcessInfo | ||
|
||
/// Resolves a configuration field for an AWS SDK feature. | ||
struct FieldResolver<T> { | ||
let configValue: T? | ||
let envVarName: String? | ||
let configFieldName: String? | ||
let fileBasedConfig: FileBasedConfiguration | ||
let profileName: String? | ||
let converter: (String) -> T? | ||
|
||
init(configValue: T?, | ||
envVarName: String?, | ||
configFieldName: String?, | ||
fileBasedConfig: FileBasedConfiguration, | ||
profileName: String?, | ||
converter: @escaping (String) -> T? | ||
) { | ||
self.configValue = configValue | ||
self.envVarName = envVarName | ||
self.configFieldName = configFieldName | ||
self.fileBasedConfig = fileBasedConfig | ||
self.profileName = profileName | ||
self.converter = converter | ||
} | ||
|
||
/// Resolves a configuration field for an AWS SDK feature. | ||
/// | ||
/// Resolves the field in the following order: | ||
/// - If `configValue` is provided, it is used. | ||
/// - If an environment var named `envVarName` is set, its value is used to create a value. | ||
/// - If a config field is set in the config file for the current profile, its value is used to create a value. | ||
/// - Finally, if none of the above yield a value, `nil` is returned. | ||
var value: T? { | ||
let env = ProcessInfo.processInfo.environment | ||
if let value = configValue { | ||
return value | ||
} | ||
if let envVarName = envVarName, let envValue = env[envVarName], let value = converter(envValue) { | ||
return value | ||
} | ||
if let configFieldName = configFieldName { | ||
let key = FileBasedConfigurationKey(rawValue: configFieldName) | ||
let envProfileName = env["AWS_PROFILE"] | ||
let sectionName = profileName ?? envProfileName ?? "default" | ||
if let configValue = fileBasedConfig.section(for: sectionName)?.string(for: key) { | ||
return converter(configValue) | ||
} | ||
} | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import struct ClientRuntime.RetryStrategyOptions | ||
|
||
enum AWSRetryConfig { | ||
|
||
/// Determines the retry mode to be used from the given config. If none can be determined, `legacy` will be used as a default. | ||
/// - Parameters: | ||
/// - configValue: The retry mode passed at client construction, or `nil` if none was passed. | ||
/// - profileName: The profile name passed at client construction. If `nil` is passed, the SDK will resolve the profile to be used. | ||
/// - fileBasedConfig: The file-based config from which to load configuration, if needed. | ||
/// - Returns: The retry mode that was resolved. | ||
static func retryMode( | ||
configValue: AWSRetryMode?, | ||
profileName: String?, | ||
fileBasedConfig: FileBasedConfiguration | ||
) -> AWSRetryMode { | ||
return FieldResolver( | ||
configValue: configValue, | ||
envVarName: "AWS_RETRY_MODE", | ||
configFieldName: "retry_mode", | ||
fileBasedConfig: fileBasedConfig, | ||
profileName: profileName, | ||
converter: { AWSRetryMode(rawValue: $0) } | ||
).value ?? .legacy | ||
} | ||
|
||
/// Determines the max attempts (for retry purposes) to be used from the given config. If none can be determined, `3` will be used as a default. | ||
/// | ||
/// Max attempts must be a positive, nonzero integer. | ||
/// - Parameters: | ||
/// - configValue: The max attempts passed at client construction, or `nil` if none was passed. | ||
/// - profileName: The profile name passed at client construction. If `nil` is passed, the SDK will resolve the profile to be used. | ||
/// - fileBasedConfig: The file-based config from which to load configuration, if needed. | ||
/// - Returns: The max attempts that was resolved. | ||
static func maxAttempts( | ||
configValue: Int?, | ||
profileName: String?, | ||
fileBasedConfig: FileBasedConfiguration | ||
) -> Int { | ||
return FieldResolver( | ||
configValue: configValue, | ||
envVarName: "AWS_MAX_ATTEMPTS", | ||
configFieldName: "max_attempts", | ||
fileBasedConfig: fileBasedConfig, | ||
profileName: profileName, | ||
converter: { Int($0) } | ||
).value ?? 3 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import Foundation | ||
|
||
/// The mode of operation for the SDK's retry mechanism. | ||
/// | ||
/// This may be specified using the `AWS_RETRY_MODE` environment var, or the `retry_mode` field of the AWS config file. | ||
public enum AWSRetryMode: String { | ||
|
||
/// Use the retry behavior that this SDK implemented before the "Retry Behavior 2.0" spec. | ||
/// For the Swift SDK, this is the same behavior as standard. | ||
case legacy | ||
|
||
/// Use "Standard" retry behavior. Initial requests are always made immediately, but retries | ||
/// are delayed using exponential backoff. Retries are performed up to the specified maximum | ||
/// number, but may be further limited by a token system. | ||
case standard | ||
|
||
/// Use "Adaptive" retry behavior. Like "Standard" but requests may be additionally delayed | ||
/// according to a rate limiting scheme that is designed to reduce congestion when throttling | ||
/// is taking place. | ||
case adaptive | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.