PATH:
home
/
shotlining
/
public_html
/
wp-content
/
plugins
/
w3-total-cache
/
vendor
/
aws
/
aws-sdk-php
/
src
<?php namespace Aws; use Aws\Exception\AwsException; use Aws\Retry\ConfigurationInterface; use Aws\Retry\QuotaManager; use Aws\Retry\RateLimiter; use Aws\Retry\RetryHelperTrait; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Promise; use Psr\Http\Message\RequestInterface; /** * Middleware that retries failures. V2 implementation that supports 'standard' * and 'adaptive' modes. * * @internal */ class RetryMiddlewareV2 { use RetryHelperTrait; private static $standardThrottlingErrors = [ 'Throttling' => true, 'ThrottlingException' => true, 'ThrottledException' => true, 'RequestThrottledException' => true, 'TooManyRequestsException' => true, 'ProvisionedThroughputExceededException' => true, 'TransactionInProgressException' => true, 'RequestLimitExceeded' => true, 'BandwidthLimitExceeded' => true, 'LimitExceededException' => true, 'RequestThrottled' => true, 'SlowDown' => true, 'PriorRequestNotComplete' => true, 'EC2ThrottledException' => true, ]; private static $standardTransientErrors = [ 'RequestTimeout' => true, 'RequestTimeoutException' => true, ]; private static $standardTransientStatusCodes = [ 500 => true, 502 => true, 503 => true, 504 => true, ]; private $collectStats; private $decider; private $delayer; private $maxAttempts; private $maxBackoff; private $mode; private $nextHandler; private $options; private $quotaManager; private $rateLimiter; public static function wrap($config, $options) { return function (callable $handler) use ( $config, $options ) { return new static( $config, $handler, $options ); }; } public static function createDefaultDecider( QuotaManager $quotaManager, $maxAttempts = 3, $options = [] ) { $retryCurlErrors = []; if (extension_loaded('curl')) { $retryCurlErrors[CURLE_RECV_ERROR] = true; } return function( $attempts, CommandInterface $command, $result ) use ($options, $quotaManager, $retryCurlErrors, $maxAttempts) { // Release retry tokens back to quota on a successful result $quotaManager->releaseToQuota($result); // Allow command-level option to override this value // # of attempts = # of retries + 1 $maxAttempts = (null !== $command['@retries']) ? $command['@retries'] + 1 : $maxAttempts; $isRetryable = self::isRetryable( $result, $retryCurlErrors, $options ); if ($isRetryable) { // Retrieve retry tokens and check if quota has been exceeded if (!$quotaManager->hasRetryQuota($result)) { return false; } if ($attempts >= $maxAttempts) { if (!empty($result) && $result instanceof AwsException) { $result->setMaxRetriesExceeded(); } return false; } } return $isRetryable; }; } public function __construct( ConfigurationInterface $config, callable $handler, $options = [] ) { $this->options = $options; $this->maxAttempts = $config->getMaxAttempts(); $this->mode = $config->getMode(); $this->nextHandler = $handler; $this->quotaManager = new QuotaManager(); $this->maxBackoff = isset($options['max_backoff']) ? $options['max_backoff'] : 20000; $this->collectStats = isset($options['collect_stats']) ? (bool) $options['collect_stats'] : false; $this->decider = isset($options['decider']) ? $options['decider'] : self::createDefaultDecider( $this->quotaManager, $this->maxAttempts, $options ); $this->delayer = isset($options['delayer']) ? $options['delayer'] : function ($attempts) { return $this->exponentialDelayWithJitter($attempts); }; if ($this->mode === 'adaptive') { $this->rateLimiter = isset($options['rate_limiter']) ? $options['rate_limiter'] : new RateLimiter(); } } public function __invoke(CommandInterface $cmd, RequestInterface $req) { $decider = $this->decider; $delayer = $this->delayer; $handler = $this->nextHandler; $attempts = 1; $monitoringEvents = []; $requestStats = []; $req = $this->addRetryHeader($req, 0, 0); $callback = function ($value) use ( $handler, $cmd, $req, $decider, $delayer, &$attempts, &$requestStats, &$monitoringEvents, &$callback ) { if ($this->mode === 'adaptive') { $this->rateLimiter->updateSendingRate($this->isThrottlingError($value)); } $this->updateHttpStats($value, $requestStats); if ($value instanceof MonitoringEventsInterface) { $reversedEvents = array_reverse($monitoringEvents); $monitoringEvents = array_merge($monitoringEvents, $value->getMonitoringEvents()); foreach ($reversedEvents as $event) { $value->prependMonitoringEvent($event); } } if ($value instanceof \Exception || $value instanceof \Throwable) { if (!$decider($attempts, $cmd, $value)) { return Promise\Create::rejectionFor( $this->bindStatsToReturn($value, $requestStats) ); } } elseif ($value instanceof ResultInterface && !$decider($attempts, $cmd, $value) ) { return $this->bindStatsToReturn($value, $requestStats); } $delayBy = $delayer($attempts++); $cmd['@http']['delay'] = $delayBy; if ($this->collectStats) { $this->updateStats($attempts - 1, $delayBy, $requestStats); } // Update retry header with retry count and delayBy $req = $this->addRetryHeader($req, $attempts - 1, $delayBy); // Get token from rate limiter, which will sleep if necessary if ($this->mode === 'adaptive') { $this->rateLimiter->getSendToken(); } return $handler($cmd, $req)->then($callback, $callback); }; // Get token from rate limiter, which will sleep if necessary if ($this->mode === 'adaptive') { $this->rateLimiter->getSendToken(); } return $handler($cmd, $req)->then($callback, $callback); } /** * Amount of milliseconds to delay as a function of attempt number * * @param $attempts * @return mixed */ public function exponentialDelayWithJitter($attempts) { $rand = mt_rand() / mt_getrandmax(); return min(1000 * $rand * pow(2, $attempts) , $this->maxBackoff); } private static function isRetryable( $result, $retryCurlErrors, $options = [] ) { $errorCodes = self::$standardThrottlingErrors + self::$standardTransientErrors; if (!empty($options['transient_error_codes']) && is_array($options['transient_error_codes']) ) { foreach($options['transient_error_codes'] as $code) { $errorCodes[$code] = true; } } if (!empty($options['throttling_error_codes']) && is_array($options['throttling_error_codes']) ) { foreach($options['throttling_error_codes'] as $code) { $errorCodes[$code] = true; } } $statusCodes = self::$standardTransientStatusCodes; if (!empty($options['status_codes']) && is_array($options['status_codes']) ) { foreach($options['status_codes'] as $code) { $statusCodes[$code] = true; } } if (!empty($options['curl_errors']) && is_array($options['curl_errors']) ) { foreach($options['curl_errors'] as $code) { $retryCurlErrors[$code] = true; } } if ($result instanceof \Exception || $result instanceof \Throwable) { $isError = true; } else { $isError = false; } if (!$isError) { if (!isset($result['@metadata']['statusCode'])) { return false; } return isset($statusCodes[$result['@metadata']['statusCode']]); } if (!($result instanceof AwsException)) { return false; } if ($result->isConnectionError()) { return true; } if (!empty($errorCodes[$result->getAwsErrorCode()])) { return true; } if (!empty($statusCodes[$result->getStatusCode()])) { return true; } if (count($retryCurlErrors) && ($previous = $result->getPrevious()) && $previous instanceof RequestException ) { if (method_exists($previous, 'getHandlerContext')) { $context = $previous->getHandlerContext(); return !empty($context['errno']) && isset($retryCurlErrors[$context['errno']]); } $message = $previous->getMessage(); foreach (array_keys($retryCurlErrors) as $curlError) { if (strpos($message, 'cURL error ' . $curlError . ':') === 0) { return true; } } } // Check error shape for the retryable trait if (!empty($errorShape = $result->getAwsErrorShape())) { $definition = $errorShape->toArray(); if (!empty($definition['retryable'])) { return true; } } return false; } private function isThrottlingError($result) { if ($result instanceof AwsException) { // Check pre-defined throttling errors $throttlingErrors = self::$standardThrottlingErrors; if (!empty($this->options['throttling_error_codes']) && is_array($this->options['throttling_error_codes']) ) { foreach($this->options['throttling_error_codes'] as $code) { $throttlingErrors[$code] = true; } } if (!empty($result->getAwsErrorCode()) && !empty($throttlingErrors[$result->getAwsErrorCode()]) ) { return true; } // Check error shape for the throttling trait if (!empty($errorShape = $result->getAwsErrorShape())) { $definition = $errorShape->toArray(); if (!empty($definition['retryable']['throttling'])) { return true; } } } return false; } }
[+]
..
[+]
Pinpoint
[+]
Chime
[+]
WellArchitected
[+]
Health
[-] IdempotencyTokenMiddleware.php
[edit]
[+]
Handler
[+]
Ssm
[+]
SecurityHub
[+]
BedrockAgentRuntime
[+]
EventBridge
[+]
SageMakerGeospatial
[+]
DefaultsMode
[+]
ResourceGroupsTaggingAPI
[+]
WAFV2
[+]
Identity
[+]
Route53
[+]
Sfn
[+]
Exception
[+]
ivschat
[+]
S3
[-] MultiRegionClient.php
[edit]
[+]
Route53Resolver
[+]
ConnectCampaignService
[+]
MigrationHubStrategyRecommendations
[+]
Sns
[+]
Ses
[+]
WafRegional
[+]
QuickSight
[+]
Sts
[+]
CloudFormation
[+]
Route53RecoveryControlConfig
[+]
WorkDocs
[+]
PinpointSMSVoiceV2
[+]
DeviceFarm
[+]
CleanRoomsML
[+]
CognitoIdentity
[+]
drs
[-] Result.php
[edit]
[+]
Ecs
[-] ClientResolver.php
[edit]
[+]
DataSync
[+]
EndpointV2
[+]
ForecastService
[+]
ConnectCases
[+]
IoTThingsGraph
[+]
TaxSettings
[+]
Route53RecoveryReadiness
[+]
AppSync
[+]
Greengrass
[+]
AppConfigData
[+]
ChimeSDKVoice
[+]
BedrockDataAutomationRuntime
[+]
MWAA
[+]
DSQL
[+]
BCMPricingCalculator
[+]
MarketplaceReporting
[+]
BedrockDataAutomation
[+]
signer
[+]
NeptuneGraph
[+]
ApplicationSignals
[+]
LookoutforVision
[+]
Translate
[+]
PrivateNetworks
[+]
CodePipeline
[+]
Iot
[+]
SupplyChain
[+]
BackupSearch
[+]
RedshiftServerless
[+]
PcaConnectorAd
[+]
CloudWatchRUM
[+]
ApiGatewayManagementApi
[+]
FraudDetector
[+]
EMRServerless
[+]
Comprehend
[+]
LexRuntimeV2
[+]
LexRuntimeService
[+]
AmplifyBackend
[+]
SnowDeviceManagement
[+]
OAM
[+]
Route53Domains
[+]
Ecr
[+]
Bedrock
[+]
Omics
[+]
PinpointSMSVoice
[+]
Lightsail
[+]
RAM
[+]
CodeCommit
[-] CommandPool.php
[edit]
[+]
TimestreamWrite
[+]
Schemas
[+]
Pipes
[-] AwsClient.php
[edit]
[+]
CloudControlApi
[-] AbstractConfigurationProvider.php
[edit]
[+]
DatabaseMigrationService
[-] InputValidationMiddleware.php
[edit]
[-] MockHandler.php
[edit]
[+]
ApplicationAutoScaling
[+]
EMRContainers
[+]
ComprehendMedical
[+]
CloudFront
[+]
Shield
[+]
NetworkFlowMonitor
[+]
WorkMail
[+]
MediaConnect
[+]
KinesisVideoMedia
[+]
IVS
[+]
ConnectWisdomService
[+]
ResourceGroups
[+]
CodeStarconnections
[+]
LaunchWizard
[+]
EKS
[+]
LicenseManager
[+]
SageMakerRuntime
[+]
GeoRoutes
[+]
AutoScaling
[+]
CostExplorer
[+]
VerifiedPermissions
[+]
finspace
[+]
Emr
[+]
Panorama
[+]
FMS
[-] TraceMiddleware.php
[edit]
[+]
NotificationsContacts
[+]
Appstream
[+]
BackupGateway
[-] AwsClientInterface.php
[edit]
[+]
MedicalImaging
[-] HasDataTrait.php
[edit]
[+]
Proton
[+]
Notifications
[+]
ServiceQuotas
[+]
MarketplaceEntitlementService
[-] ResultPaginator.php
[edit]
[-] QueryCompatibleInputMiddleware.php
[edit]
[+]
MainframeModernization
[+]
OpsWorksCM
[+]
CodeBuild
[+]
imagebuilder
[+]
ElasticTranscoder
[+]
Budgets
[+]
IoTSecureTunneling
[+]
Route53RecoveryCluster
[+]
AppMesh
[-] RetryMiddlewareV2.php
[edit]
[+]
Multipart
[+]
IoTDeviceAdvisor
[+]
Waf
[+]
Polly
[+]
FSx
[+]
CloudFrontKeyValueStore
[+]
Inspector2
[+]
XRay
[-] LruArrayCache.php
[edit]
[+]
KinesisVideoSignalingChannels
[+]
Athena
[+]
ConnectCampaignsV2
[+]
InspectorScan
[+]
WorkMailMessageFlow
[+]
AmplifyUIBuilder
[+]
ApiGatewayV2
[+]
PaymentCryptography
[+]
EBS
[+]
Billing
[+]
Endpoint
[-] Waiter.php
[edit]
[+]
MediaLive
[+]
SecretsManager
[+]
LakeFormation
[+]
ServerlessApplicationRepository
[+]
FIS
[+]
Macie2
[+]
RedshiftDataAPIService
[-] MonitoringEventsInterface.php
[edit]
[+]
Credentials
[+]
ResourceExplorer2
[+]
PartnerCentralSelling
[+]
MigrationHub
[+]
MarketplaceCommerceAnalytics
[+]
MTurk
[-] RetryMiddleware.php
[edit]
[+]
IoTEventsData
[+]
KinesisVideoWebRTCStorage
[+]
MediaStore
[+]
Amplify
[+]
BillingConductor
[+]
Kms
[+]
CognitoSync
[+]
Efs
[+]
WorkSpacesThinClient
[+]
DAX
[+]
CloudWatchLogs
[+]
ChimeSDKMessaging
[+]
Rekognition
[+]
EKSAuth
[+]
ChimeSDKIdentity
[+]
RolesAnywhere
[+]
CodeConnections
[+]
CostOptimizationHub
[+]
ForecastQueryService
[+]
GeoMaps
[+]
CodeStarNotifications
[+]
ApplicationCostProfiler
[+]
LicenseManagerUserSubscriptions
[+]
StorageGateway
[-] functions.php
[edit]
[+]
GlueDataBrew
[+]
Iam
[+]
Glacier
[+]
CodeGuruSecurity
[+]
BCMDataExports
[+]
AppRunner
[+]
Batch
[+]
Swf
[+]
MediaTailor
[+]
KendraRanking
[+]
SSO
[+]
PersonalizeEvents
[+]
EC2InstanceConnect
[+]
DataZone
[+]
MediaStoreData
[+]
IoTEvents
[+]
PCS
[-] EndpointParameterMiddleware.php
[edit]
[-] HasMonitoringEventsTrait.php
[edit]
[+]
SavingsPlans
[+]
SSMContacts
[-] Middleware.php
[edit]
[+]
Rds
[+]
AppTest
[+]
Sqs
[+]
IotDataPlane
[+]
ControlTower
[+]
CloudHsm
[+]
CodeCatalyst
[-] RequestCompressionMiddleware.php
[edit]
[+]
IoTFleetWise
[+]
VPCLattice
[+]
Lambda
[+]
FreeTier
[+]
SSMIncidents
[+]
MediaConvert
[+]
IoTTwinMaker
[+]
ImportExport
[+]
SageMakerFeatureStoreRuntime
[+]
DataExchange
[+]
PI
[+]
CodeDeploy
[+]
ACMPCA
[-] CacheInterface.php
[edit]
[+]
Synthetics
[-] StreamRequestPayloadMiddleware.php
[edit]
[+]
ConnectParticipant
[+]
OpsWorks
[+]
DocDBElastic
[+]
ElasticLoadBalancing
[+]
KinesisAnalytics
[+]
CloudSearch
[-] MetricsBuilder.php
[edit]
[+]
CloudTrail
[+]
ElasticBeanstalk
[+]
IoTAnalytics
[+]
MarketplaceAgreement
[-] CommandInterface.php
[edit]
[-] PresignUrlMiddleware.php
[edit]
[+]
Transfer
[+]
EndpointDiscovery
[+]
Backup
[+]
ConfigService
[+]
ManagedBlockchain
[+]
Firehose
[+]
SSMQuickSetup
[+]
Arn
[+]
PersonalizeRuntime
[+]
GuardDuty
[-] Psr16CacheAdapter.php
[edit]
[+]
Textract
[+]
KafkaConnect
[+]
SimSpaceWeaver
[+]
Detective
[+]
GreengrassV2
[+]
SsmSap
[+]
Account
[+]
ElasticsearchService
[+]
KinesisVideo
[+]
QApps
[+]
AutoScalingPlans
[+]
MediaPackage
[+]
AuditManager
[+]
TimestreamInfluxDB
[+]
MediaPackageV2
[+]
Redshift
[+]
IoTSiteWise
[+]
B2bi
[+]
SupportApp
[+]
ComputeOptimizer
[+]
ResilienceHub
[+]
Crypto
[+]
ApiGateway
[+]
CloudHSMV2
[+]
MemoryDB
[+]
ManagedGrafana
[-] JsonCompiler.php
[edit]
[+]
ManagedBlockchainQuery
[+]
ObservabilityAdmin
[+]
AppRegistry
[+]
LexModelsV2
[-] AwsClientTrait.php
[edit]
[+]
LicenseManagerLinuxSubscriptions
[+]
GroundStation
[+]
MigrationHubRefactorSpaces
[+]
NetworkManager
[+]
Route53Profiles
[+]
IVSRealTime
[+]
Invoicing
[+]
Support
[+]
CodeGuruProfiler
[+]
MachineLearning
[+]
S3Tables
[+]
ChimeSDKMeetings
[+]
TrustedAdvisor
[+]
AccessAnalyzer
[+]
ServiceCatalog
[+]
Ec2
[+]
IoTFleetHub
[+]
WorkSpacesWeb
[+]
LocationService
[+]
Deadline
[+]
Neptune
[+]
DynamoDb
[-] ResultInterface.php
[edit]
[+]
Appflow
[+]
SnowBall
[+]
EntityResolution
[+]
WorkSpaces
[+]
TranscribeService
[+]
MQ
[+]
Inspector
[-] History.php
[edit]
[+]
ConnectContactLens
[+]
IoTJobsDataPlane
[+]
KinesisVideoArchivedMedia
[+]
DLM
[+]
ApplicationInsights
[+]
ElastiCache
[+]
Configuration
[+]
VoiceID
[+]
SecurityLake
[+]
LookoutEquipment
[-] ConfigurationProviderInterface.php
[edit]
[+]
Artifact
[+]
ClientSideMonitoring
[+]
QConnect
[+]
MarketplaceMetering
[+]
PaymentCryptographyData
[+]
Neptunedata
[+]
AppConfig
[+]
ServiceDiscovery
[+]
mgn
[+]
NetworkMonitor
[+]
CustomerProfiles
[+]
Auth
[+]
BedrockAgent
[+]
RoboMaker
[+]
MarketplaceDeployment
[+]
SSOAdmin
[+]
DataPipeline
[+]
DevOpsGuru
[+]
Repostspace
[+]
Glue
[+]
SageMakerMetrics
[+]
LexModelBuildingService
[+]
Pricing
[+]
S3Outposts
[+]
ChimeSDKMediaPipelines
[-] HandlerList.php
[edit]
[+]
ApplicationDiscoveryService
[+]
RDSDataService
[+]
SagemakerEdgeManager
[+]
AppFabric
[+]
QLDBSession
[-] Sdk.php
[edit]
[+]
AugmentedAIRuntime
[+]
CloudSearchDomain
[+]
CostandUsageReportService
[+]
Personalize
[+]
Api
[+]
Braket
[+]
DirectoryService
[+]
DynamoDbStreams
[+]
SesV2
[+]
Retry
[+]
Sms
[+]
Tnb
[+]
Token
[+]
QBusiness
[-] HashingStream.php
[edit]
[-] PhpHash.php
[edit]
[+]
Kinesis
[+]
Script
[-] PsrCacheAdapter.php
[edit]
[-] ResponseContainerInterface.php
[edit]
[+]
CloudWatchEvents
[+]
SSOOIDC
[-] WrappedHttpHandler.php
[edit]
[+]
ARCZonalShift
[+]
Keyspaces
[-] HashInterface.php
[edit]
[-] UserAgentMiddleware.php
[edit]
[+]
CodeGuruReviewer
[+]
Organizations
[+]
OpenSearchServerless
[+]
KinesisAnalyticsV2
[+]
OSIS
[+]
TimestreamQuery
[+]
NetworkFirewall
[+]
MarketplaceCatalog
[+]
ElasticLoadBalancingV2
[+]
PrometheusService
[+]
CodeArtifact
[+]
Outposts
[+]
IdentityStore
[+]
Cloud9
[+]
FinSpaceData
[+]
PinpointEmail
[+]
SageMaker
[+]
S3Control
[+]
Chatbot
[+]
OpenSearchService
[+]
InternetMonitor
[+]
GlobalAccelerator
[-] Command.php
[edit]
[+]
PcaConnectorScep
[+]
Acm
[+]
LookoutMetrics
[+]
Scheduler
[+]
ElasticInference
[+]
QLDB
[+]
CloudTrailData
[+]
kendra
[+]
data
[+]
SecurityIR
[+]
GeoPlaces
[+]
BedrockRuntime
[+]
MailManager
[-] DoctrineCacheAdapter.php
[edit]
[+]
MediaPackageVod
[+]
RecycleBin
[+]
CognitoIdentityProvider
[+]
CleanRooms
[+]
MigrationHubConfig
[+]
CloudWatchEvidently
[+]
DocDB
[+]
ECRPublic
[+]
Signature
[+]
GameLift
[+]
Connect
[+]
IoTWireless
[+]
Kafka
[+]
CloudWatch
[+]
ControlCatalog
[+]
CloudDirectory
[+]
SocialMessaging
[+]
DirectConnect
[+]
MigrationHubOrchestrator
[+]
HealthLake
[+]
AppIntegrationsService
[+]
DirectoryServiceData