mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-14 02:27:23 -07:00
v2: Updates
* Simplifies & beautifies everything * Introduces a new Class system. * Errors are defaulted to AWS's handler. * New function names & more efficient handling. * Should fix a majority of the errors. Please read the README for more!
This commit is contained in:
parent
ad0726e41e
commit
e6d7753dc8
1095 changed files with 45088 additions and 2911 deletions
56
aws/Aws/Retry/RetryHelperTrait.php
Normal file
56
aws/Aws/Retry/RetryHelperTrait.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
namespace Aws\Retry;
|
||||
|
||||
use Aws\Exception\AwsException;
|
||||
use Aws\ResultInterface;
|
||||
|
||||
trait RetryHelperTrait
|
||||
{
|
||||
private function addRetryHeader($request, $retries, $delayBy)
|
||||
{
|
||||
return $request->withHeader('aws-sdk-retry', "{$retries}/{$delayBy}");
|
||||
}
|
||||
|
||||
|
||||
private function updateStats($retries, $delay, array &$stats)
|
||||
{
|
||||
if (!isset($stats['total_retry_delay'])) {
|
||||
$stats['total_retry_delay'] = 0;
|
||||
}
|
||||
|
||||
$stats['total_retry_delay'] += $delay;
|
||||
$stats['retries_attempted'] = $retries;
|
||||
}
|
||||
|
||||
private function updateHttpStats($value, array &$stats)
|
||||
{
|
||||
if (empty($stats['http'])) {
|
||||
$stats['http'] = [];
|
||||
}
|
||||
|
||||
if ($value instanceof AwsException) {
|
||||
$resultStats = $value->getTransferInfo();
|
||||
$stats['http'] []= $resultStats;
|
||||
} elseif ($value instanceof ResultInterface) {
|
||||
$resultStats = isset($value['@metadata']['transferStats']['http'][0])
|
||||
? $value['@metadata']['transferStats']['http'][0]
|
||||
: [];
|
||||
$stats['http'] []= $resultStats;
|
||||
}
|
||||
}
|
||||
|
||||
private function bindStatsToReturn($return, array $stats)
|
||||
{
|
||||
if ($return instanceof ResultInterface) {
|
||||
if (!isset($return['@metadata'])) {
|
||||
$return['@metadata'] = [];
|
||||
}
|
||||
|
||||
$return['@metadata']['transferStats'] = $stats;
|
||||
} elseif ($return instanceof AwsException) {
|
||||
$return->setTransferInfo($stats);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue