Implemented retry logic for HTTP requests in Repositories
This commit is contained in:
parent
cf7e1aa107
commit
8ce6c68d77
4 changed files with 55 additions and 7 deletions
|
@ -474,11 +474,23 @@
|
||||||
*/
|
*/
|
||||||
private static function processHttpResponse(CurlHandle $curl, string $group, string $project): array
|
private static function processHttpResponse(CurlHandle $curl, string $group, string $project): array
|
||||||
{
|
{
|
||||||
$response = curl_exec($curl);
|
$retry_count = 0;
|
||||||
|
$response = false;
|
||||||
|
|
||||||
|
while($retry_count < 3 && $response === false)
|
||||||
|
{
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
|
||||||
|
if($response === false)
|
||||||
|
{
|
||||||
|
Console::outWarning(sprintf('HTTP request failed for %s/%s: %s, retrying (%s/3)', $vendor, $project, curl_error($curl), $retry_count + 1));
|
||||||
|
$retry_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($response === false)
|
if($response === false)
|
||||||
{
|
{
|
||||||
throw new NetworkException(sprintf('HTTP request failed for %s/%s: %s', $group, $project, curl_error($curl)));
|
throw new NetworkException(sprintf('HTTP request failed for %s/%s: %s', $vendor, $project, curl_error($curl)));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(curl_getinfo($curl, CURLINFO_HTTP_CODE))
|
switch(curl_getinfo($curl, CURLINFO_HTTP_CODE))
|
||||||
|
|
|
@ -472,11 +472,23 @@
|
||||||
*/
|
*/
|
||||||
private static function processHttpResponse(CurlHandle $curl, string $group, string $project): array
|
private static function processHttpResponse(CurlHandle $curl, string $group, string $project): array
|
||||||
{
|
{
|
||||||
$response = curl_exec($curl);
|
$retry_count = 0;
|
||||||
|
$response = false;
|
||||||
|
|
||||||
|
while($retry_count < 3 && $response === false)
|
||||||
|
{
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
|
||||||
|
if($response === false)
|
||||||
|
{
|
||||||
|
Console::outWarning(sprintf('HTTP request failed for %s/%s: %s, retrying (%s/3)', $vendor, $project, curl_error($curl), $retry_count + 1));
|
||||||
|
$retry_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($response === false)
|
if($response === false)
|
||||||
{
|
{
|
||||||
throw new NetworkException(sprintf('HTTP request failed for %s/%s: %s', $group, $project, curl_error($curl)));
|
throw new NetworkException(sprintf('HTTP request failed for %s/%s: %s', $vendor, $project, curl_error($curl)));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (curl_getinfo($curl, CURLINFO_HTTP_CODE))
|
switch (curl_getinfo($curl, CURLINFO_HTTP_CODE))
|
||||||
|
|
|
@ -495,11 +495,23 @@
|
||||||
*/
|
*/
|
||||||
private static function processHttpResponse(CurlHandle $curl, string $group, string $project): array
|
private static function processHttpResponse(CurlHandle $curl, string $group, string $project): array
|
||||||
{
|
{
|
||||||
$response = curl_exec($curl);
|
$retry_count = 0;
|
||||||
|
$response = false;
|
||||||
|
|
||||||
|
while($retry_count < 3 && $response === false)
|
||||||
|
{
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
|
||||||
|
if($response === false)
|
||||||
|
{
|
||||||
|
Console::outWarning(sprintf('HTTP request failed for %s/%s: %s, retrying (%s/3)', $vendor, $project, curl_error($curl), $retry_count + 1));
|
||||||
|
$retry_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($response === false)
|
if($response === false)
|
||||||
{
|
{
|
||||||
throw new NetworkException(sprintf('HTTP request failed for %s/%s: %s', $group, $project, curl_error($curl)));
|
throw new NetworkException(sprintf('HTTP request failed for %s/%s: %s', $vendor, $project, curl_error($curl)));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (curl_getinfo($curl, CURLINFO_HTTP_CODE))
|
switch (curl_getinfo($curl, CURLINFO_HTTP_CODE))
|
||||||
|
|
|
@ -231,7 +231,19 @@
|
||||||
*/
|
*/
|
||||||
private static function processHttpResponse(CurlHandle $curl, string $vendor, string $project): array
|
private static function processHttpResponse(CurlHandle $curl, string $vendor, string $project): array
|
||||||
{
|
{
|
||||||
$response = curl_exec($curl);
|
$retry_count = 0;
|
||||||
|
$response = false;
|
||||||
|
|
||||||
|
while($retry_count < 3 && $response === false)
|
||||||
|
{
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
|
||||||
|
if($response === false)
|
||||||
|
{
|
||||||
|
Console::outWarning(sprintf('HTTP request failed for %s/%s: %s, retrying (%s/3)', $vendor, $project, curl_error($curl), $retry_count + 1));
|
||||||
|
$retry_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($response === false)
|
if($response === false)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue