|
8 | 8 | use AsyncAws\Core\Credentials\ChainProvider;
|
9 | 9 | use AsyncAws\Core\Credentials\CredentialProvider;
|
10 | 10 | use AsyncAws\Core\Credentials\SymfonyCacheProvider;
|
| 11 | +use AsyncAws\Core\HttpClient\AwsRetryStrategy; |
11 | 12 | use AsyncAws\Symfony\Bundle\Secrets\CachedEnvVarLoader;
|
12 | 13 | use AsyncAws\Symfony\Bundle\Secrets\SsmVault;
|
13 | 14 | use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
| 15 | +use Symfony\Component\DependencyInjection\ChildDefinition; |
14 | 16 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
15 | 17 | use Symfony\Component\DependencyInjection\ContainerInterface;
|
16 | 18 | use Symfony\Component\DependencyInjection\Definition;
|
17 | 19 | use Symfony\Component\DependencyInjection\Reference;
|
| 20 | +use Symfony\Component\HttpClient\Retry\RetryStrategyInterface; |
| 21 | +use Symfony\Component\HttpClient\RetryableHttpClient; |
18 | 22 | use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
19 | 23 | use Symfony\Contracts\Cache\CacheInterface;
|
20 | 24 |
|
@@ -94,7 +98,17 @@ private function addServiceDefinition(ContainerBuilder $container, string $name,
|
94 | 98 | $httpClient = $config['http_client'] ? new Reference($config['http_client']) : null;
|
95 | 99 | } else {
|
96 | 100 | // Use default Symfony http_client unless explicitly set to null.
|
97 |
| - $httpClient = new Reference('http_client', ContainerInterface::NULL_ON_INVALID_REFERENCE); |
| 101 | + if (class_exists(RetryableHttpClient::class)) { |
| 102 | + $httpClient = new Definition(RetryableHttpClient::class); |
| 103 | + $httpClient->setArguments([ |
| 104 | + new Reference('async_aws.http_client'), |
| 105 | + new Definition(AwsRetryStrategy::class), |
| 106 | + 3, |
| 107 | + $logger, |
| 108 | + ]); |
| 109 | + } else { |
| 110 | + $httpClient = new Reference('async_aws.http_client'); |
| 111 | + } |
98 | 112 | }
|
99 | 113 |
|
100 | 114 | // If no credential provider is specified, lets configured a credentials provider with cache.
|
@@ -126,10 +140,12 @@ private function addServiceDefinition(ContainerBuilder $container, string $name,
|
126 | 140 | }
|
127 | 141 |
|
128 | 142 | $definition = new Definition($clientClass);
|
129 |
| - $definition->addArgument($config['config']); |
130 |
| - $definition->addArgument($credentialServiceId ? new Reference($credentialServiceId) : null); |
131 |
| - $definition->addArgument($httpClient); |
132 |
| - $definition->addArgument($logger); |
| 143 | + $definition->setArguments([ |
| 144 | + $config['config'], |
| 145 | + $credentialServiceId ? new Reference($credentialServiceId) : null, |
| 146 | + $httpClient, |
| 147 | + $logger, |
| 148 | + ]); |
133 | 149 | $definition->addTag('monolog.logger', ['channel' => 'async_aws']);
|
134 | 150 | $container->setDefinition(sprintf('async_aws.client.%s', $name), $definition);
|
135 | 151 | }
|
|
0 commit comments