Skip to content

Commit 9eaf5c5

Browse files
authored
Simplify HttpClient injection (#1162)
1 parent 189cfdc commit 9eaf5c5

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Added
66

7+
- Make the injected HttpClient decorated by our `RetryableHttpClient`
78
- Support for KMS
89

910
## 1.13.0

src/AbstractApi.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ public function __construct($configuration = [], ?CredentialProvider $credential
7474
$this->awsErrorFactory = $this->getAwsErrorFactory();
7575
if (!isset($httpClient)) {
7676
$httpClient = HttpClient::create();
77-
if (class_exists(RetryableHttpClient::class)) {
78-
/** @psalm-suppress MissingDependency */
79-
$httpClient = new RetryableHttpClient(
80-
$httpClient,
81-
new AwsRetryStrategy(AwsRetryStrategy::DEFAULT_RETRY_STATUS_CODES, 1000, 2.0, 0, 0.1, $this->awsErrorFactory),
82-
3,
83-
$this->logger
84-
);
85-
}
77+
}
78+
if (class_exists(RetryableHttpClient::class) && !$httpClient instanceof RetryableHttpClient) {
79+
/** @psalm-suppress MissingDependency */
80+
$httpClient = new RetryableHttpClient(
81+
$httpClient,
82+
new AwsRetryStrategy(AwsRetryStrategy::DEFAULT_RETRY_STATUS_CODES, 1000, 2.0, 0, 0.1, $this->awsErrorFactory),
83+
3,
84+
$this->logger
85+
);
8686
}
8787
$this->httpClient = $httpClient;
8888
$this->configuration = $configuration;

0 commit comments

Comments
 (0)