-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd4795e
commit 88bcec3
Showing
7 changed files
with
88 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@smithy/smithy-client": minor | ||
"@smithy/types": minor | ||
--- | ||
|
||
Add retry to runtime extension |
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
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,29 @@ | ||
import { Provider, RetryStrategy, RetryStrategyConfiguration, RetryStrategyV2 } from "@smithy/types"; | ||
|
||
export type PartialRetryRuntimeConfigType = Partial<{ retryStrategy: Provider<RetryStrategyV2 | RetryStrategy> }>; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const getRetryConfiguration = (runtimeConfig: PartialRetryRuntimeConfigType) => { | ||
let _retryStrategy = runtimeConfig.retryStrategy!; | ||
return { | ||
setRetryStrategy(retryStrategy: Provider<RetryStrategyV2 | RetryStrategy>): void { | ||
_retryStrategy = retryStrategy; | ||
}, | ||
retryStrategy(): Provider<RetryStrategyV2 | RetryStrategy> { | ||
return _retryStrategy; | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const resolveRetryRuntimeConfig = ( | ||
retryStrategyConfiguration: RetryStrategyConfiguration | ||
): PartialRetryRuntimeConfigType => { | ||
const runtimeConfig: PartialRetryRuntimeConfigType = {}; | ||
runtimeConfig.retryStrategy = retryStrategyConfiguration.retryStrategy(); | ||
return runtimeConfig; | ||
}; |
5 changes: 2 additions & 3 deletions
5
packages/types/src/extensions/defaultExtensionConfiguration.ts
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,10 +1,9 @@ | ||
import { ChecksumConfiguration } from "./checksum"; | ||
import { RetryStrategyConfiguration } from "./retry"; | ||
|
||
/** | ||
* @internal | ||
* | ||
* Default extension configuration consisting various configurations for modifying a service client | ||
*/ | ||
export interface DefaultExtensionConfiguration extends ChecksumConfiguration {} | ||
|
||
type GetDefaultConfigurationType = (runtimeConfig: any) => DefaultExtensionConfiguration; | ||
export interface DefaultExtensionConfiguration extends ChecksumConfiguration, RetryStrategyConfiguration {} |
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,3 +1,4 @@ | ||
export * from "./defaultClientConfiguration"; | ||
export * from "./defaultExtensionConfiguration"; | ||
export { AlgorithmId, ChecksumAlgorithm, ChecksumConfiguration } from "./checksum"; | ||
export { RetryStrategyConfiguration } from "./retry"; |
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,20 @@ | ||
import { RetryStrategyV2 } from "../retry"; | ||
import { Provider, RetryStrategy } from "../util"; | ||
|
||
/** | ||
* A configuration interface with methods called by runtime extension | ||
* @internal | ||
*/ | ||
export interface RetryStrategyConfiguration { | ||
/** | ||
* Set retry strategy used for all http requests | ||
* @param retryStrategy | ||
*/ | ||
setRetryStrategy(retryStrategy: Provider<RetryStrategyV2 | RetryStrategy>): void; | ||
|
||
/** | ||
* Get retry strategy used for all http requests | ||
* @param retryStrategy | ||
*/ | ||
retryStrategy(): Provider<RetryStrategyV2 | RetryStrategy>; | ||
} |