|
27 | 27 | use Aws\EndpointDiscovery\ConfigurationInterface; |
28 | 28 | use Aws\EndpointDiscovery\ConfigurationProvider; |
29 | 29 | use Aws\EndpointV2\EndpointDefinitionProvider; |
| 30 | +use Aws\EndpointV2\EndpointProviderV2; |
30 | 31 | use Aws\Exception\AwsException; |
31 | 32 | use Aws\Exception\InvalidRegionException; |
32 | 33 | use Aws\Retry\ConfigurationInterface as RetryConfigInterface; |
33 | 34 | use Aws\Retry\ConfigurationProvider as RetryConfigProvider; |
| 35 | +use Aws\Retry\V3\OptIn as NewRetriesOptIn; |
| 36 | +use Aws\Retry\V3\RetryMiddleware as RetryV3Middleware; |
34 | 37 | use Aws\Signature\SignatureProvider; |
35 | 38 | use Aws\Token\Token; |
36 | 39 | use Aws\Token\TokenInterface; |
@@ -547,28 +550,42 @@ private function throwRequired(array $args) |
547 | 550 | public static function _apply_retries($value, array &$args, HandlerList $list) |
548 | 551 | { |
549 | 552 | // A value of 0 for the config option disables retries |
550 | | - if ($value) { |
551 | | - $config = RetryConfigProvider::unwrap($value); |
| 553 | + if (!$value) { |
| 554 | + return; |
| 555 | + } |
552 | 556 |
|
553 | | - if ($config->getMode() === 'legacy') { |
554 | | - // # of retries is 1 less than # of attempts |
555 | | - $decider = RetryMiddleware::createDefaultDecider( |
556 | | - $config->getMaxAttempts() - 1 |
557 | | - ); |
558 | | - $list->appendSign( |
559 | | - Middleware::retry($decider, null, $args['stats']['retries']), |
560 | | - 'retry' |
561 | | - ); |
562 | | - } else { |
563 | | - $list->appendSign( |
564 | | - RetryMiddlewareV2::wrap( |
565 | | - $config, |
566 | | - ['collect_stats' => $args['stats']['retries']] |
567 | | - ), |
568 | | - 'retry' |
569 | | - ); |
570 | | - } |
| 557 | + $config = RetryConfigProvider::unwrap($value); |
| 558 | + |
| 559 | + if ($config->getMode() === 'legacy') { |
| 560 | + // # of retries is 1 less than # of attempts |
| 561 | + $decider = RetryMiddleware::createDefaultDecider( |
| 562 | + $config->getMaxAttempts() - 1 |
| 563 | + ); |
| 564 | + $list->appendSign( |
| 565 | + Middleware::retry($decider, null, $args['stats']['retries']), |
| 566 | + 'retry' |
| 567 | + ); |
| 568 | + return; |
| 569 | + } |
| 570 | + |
| 571 | + if (NewRetriesOptIn::isEnabled()) { |
| 572 | + $list->appendSign( |
| 573 | + RetryV3Middleware::wrap($config, [ |
| 574 | + 'collect_stats' => $args['stats']['retries'], |
| 575 | + 'service' => $args['service'], |
| 576 | + ]), |
| 577 | + 'retry' |
| 578 | + ); |
| 579 | + return; |
571 | 580 | } |
| 581 | + |
| 582 | + $list->appendSign( |
| 583 | + RetryMiddlewareV2::wrap( |
| 584 | + $config, |
| 585 | + ['collect_stats' => $args['stats']['retries']] |
| 586 | + ), |
| 587 | + 'retry' |
| 588 | + ); |
572 | 589 | } |
573 | 590 |
|
574 | 591 | public static function _apply_defaults($value, array &$args, HandlerList $list) |
@@ -791,7 +808,7 @@ public static function _apply_api_provider(callable $value, array &$args) |
791 | 808 | public static function _apply_endpoint_provider($value, array &$args) |
792 | 809 | { |
793 | 810 | if (!isset($args['endpoint'])) { |
794 | | - if ($value instanceof \Aws\EndpointV2\EndpointProviderV2) { |
| 811 | + if ($value instanceof EndpointProviderV2) { |
795 | 812 | $options = self::getEndpointProviderOptions($args); |
796 | 813 | $value = PartitionEndpointProvider::defaultProvider($options) |
797 | 814 | ->getPartition($args['region'], $args['service']); |
@@ -1112,14 +1129,13 @@ public static function _default_endpoint_provider(array $args) |
1112 | 1129 | if (self::isValidService($serviceName) |
1113 | 1130 | && self::isValidApiVersion($serviceName, $apiVersion) |
1114 | 1131 | ) { |
1115 | | - $ruleset = EndpointDefinitionProvider::getEndpointRuleset( |
| 1132 | + $partitions = EndpointDefinitionProvider::getPartitions(); |
| 1133 | + $parsed = EndpointDefinitionProvider::getParsedRuleset( |
1116 | 1134 | $service->getServiceName(), |
1117 | | - $service->getApiVersion() |
1118 | | - ); |
1119 | | - return new \Aws\EndpointV2\EndpointProviderV2( |
1120 | | - $ruleset, |
1121 | | - EndpointDefinitionProvider::getPartitions() |
| 1135 | + $service->getApiVersion(), |
| 1136 | + $partitions |
1122 | 1137 | ); |
| 1138 | + return new EndpointProviderV2($parsed, $partitions); |
1123 | 1139 | } |
1124 | 1140 | $options = self::getEndpointProviderOptions($args); |
1125 | 1141 | return PartitionEndpointProvider::defaultProvider($options) |
|
0 commit comments