-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add retry and http client plugins
- Loading branch information
1 parent
c6430c4
commit d553ad3
Showing
16 changed files
with
315 additions
and
57 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
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,33 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
public class DefaultHttpClientPlugin: Plugin { | ||
|
||
var httpClientConfiguration: HttpClientConfiguration | ||
|
||
var httpClient: HTTPClient | ||
|
||
public init(httpClient: HTTPClient, httpClientConfiguration: HttpClientConfiguration) { | ||
self.httpClient = httpClient | ||
self.httpClientConfiguration = httpClientConfiguration | ||
} | ||
|
||
public convenience init(httpClientConfiguration: HttpClientConfiguration) { | ||
self.init( | ||
httpClient: DefaultSDKRuntimeConfiguration<DefaultRetryStrategy, DefaultRetryErrorInfoProvider> | ||
.makeClient(httpClientConfiguration: httpClientConfiguration), | ||
httpClientConfiguration: httpClientConfiguration | ||
) | ||
} | ||
|
||
public func configureClient(clientConfiguration: ClientConfiguration) { | ||
if var config = clientConfiguration as? DefaultHttpClientConfiguration { | ||
config.httpClientConfiguration = self.httpClientConfiguration | ||
config.httpClientEngine = self.httpClient | ||
} | ||
} | ||
} |
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,21 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
public class RetryPlugin: Plugin { | ||
|
||
private var retryStrategyOptions: RetryStrategyOptions | ||
|
||
public init(retryStrategyOptions: RetryStrategyOptions) { | ||
self.retryStrategyOptions = retryStrategyOptions | ||
} | ||
|
||
public func configureClient(clientConfiguration: ClientConfiguration) { | ||
if var config = clientConfiguration as? DefaultClientConfiguration { | ||
config.retryStrategyOptions = self.retryStrategyOptions | ||
} | ||
} | ||
} |
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
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
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.