Skip to content

Commit

Permalink
AUT-512: Fix method signature in retry logic
Browse files Browse the repository at this point in the history
Co-authored-by: Bence Kadar <bence.kadar@emarsys.com>
  • Loading branch information
lloki-emarsys and bencekadaremar committed Jul 7, 2022
1 parent e594d15 commit 2cf047d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Suite/Api/Middleware/Retry.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Suite\Api\Middleware;

use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\TransferException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Psr\Log\LoggerInterface;
Expand All @@ -27,7 +27,7 @@ public function __construct(LoggerInterface $logger, int $maxRetryCount = 1)

public function createHandler()
{
return function (int $retries, Request $request, Response $response = null, RequestException $exception = null) {
return function (int $retries, Request $request, Response $response = null, TransferException $exception = null) {
if ($this->stillHasRetryAttempts($retries) && $this->isRetriableError($response, $exception)) {
$this->log($retries, $request, $response, $exception);
return true;
Expand All @@ -51,12 +51,12 @@ private function isServerError(Response $response = null)
return $response && $response->getStatusCode() >= 500;
}

private function isConnectError(RequestException $exception = null)
private function isConnectError(TransferException $exception = null)
{
return $exception instanceof ConnectException;
}

private function log(int $retries, Request $request, Response $response = null, RequestException $exception = null)
private function log(int $retries, Request $request, Response $response = null, TransferException $exception = null)
{
$this->logger->warning(
'Retrying API call',
Expand Down

0 comments on commit 2cf047d

Please sign in to comment.