|
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\AwsHttpClientFactory; |
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;
|
|
17 | 18 | use Symfony\Component\DependencyInjection\Reference;
|
18 | 19 | use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
19 | 20 | use Symfony\Contracts\Cache\CacheInterface;
|
| 21 | +use Symfony\Contracts\HttpClient\HttpClientInterface; |
20 | 22 |
|
21 | 23 | class AsyncAwsExtension extends Extension
|
22 | 24 | {
|
@@ -94,7 +96,16 @@ private function addServiceDefinition(ContainerBuilder $container, string $name,
|
94 | 96 | $httpClient = $config['http_client'] ? new Reference($config['http_client']) : null;
|
95 | 97 | } else {
|
96 | 98 | // Use default Symfony http_client unless explicitly set to null.
|
97 |
| - $httpClient = new Reference('http_client', ContainerInterface::NULL_ON_INVALID_REFERENCE); |
| 99 | + if (class_exists(AwsHttpClientFactory::class)) { |
| 100 | + $httpClient = new Definition(HttpClientInterface::class); |
| 101 | + $httpClient->setFactory([AwsHttpClientFactory::class, 'createRetryableClient']) |
| 102 | + ->setArguments([ |
| 103 | + new Reference('http_clients', ContainerInterface::NULL_ON_INVALID_REFERENCE), |
| 104 | + $logger, |
| 105 | + ]); |
| 106 | + } else { |
| 107 | + $httpClient = new Reference('http_client', ContainerInterface::NULL_ON_INVALID_REFERENCE); |
| 108 | + } |
98 | 109 | }
|
99 | 110 |
|
100 | 111 | // If no credential provider is specified, lets configured a credentials provider with cache.
|
@@ -126,10 +137,12 @@ private function addServiceDefinition(ContainerBuilder $container, string $name,
|
126 | 137 | }
|
127 | 138 |
|
128 | 139 | $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); |
| 140 | + $definition->setArguments([ |
| 141 | + $config['config'], |
| 142 | + $credentialServiceId ? new Reference($credentialServiceId) : null, |
| 143 | + $httpClient, |
| 144 | + $logger, |
| 145 | + ]); |
133 | 146 | $definition->addTag('monolog.logger', ['channel' => 'async_aws']);
|
134 | 147 | $container->setDefinition(sprintf('async_aws.client.%s', $name), $definition);
|
135 | 148 | }
|
|
0 commit comments