diff --git a/DependencyInjection/Compiler/MappingPass.php b/DependencyInjection/Compiler/MappingPass.php index aedbb614..c095bc6b 100644 --- a/DependencyInjection/Compiler/MappingPass.php +++ b/DependencyInjection/Compiler/MappingPass.php @@ -107,7 +107,7 @@ private function getBundlesMetadata(ContainerBuilder $container, $settings) $metadataDefinition->addArgument([$repository => $metadata]); if (strpos($bundle, ':') === false) { - $out[$bundle . ':' . $metadata['class']] = $metadataDefinition; + $out[$bundle.':'.$metadata['class']] = $metadataDefinition; } else { $out[$bundle] = $metadataDefinition; } @@ -132,7 +132,7 @@ private function getConnectionDefinition(ContainerBuilder $container, $connectio { if (!isset($connections[$settings['connection']])) { throw new InvalidConfigurationException( - 'There is no ES connection with name ' . $settings['connection'] + 'There is no ES connection with name '.$settings['connection'] ); } @@ -174,6 +174,16 @@ private function getClientParams(array $connection, array $manager, ContainerBui $params['connectionParams']['auth'] = array_values($connection['auth']); } + if (!empty($connection['curl_options']) && !empty($connection['curl_options']['connection_timeout'])) { + $connectionTimeout = $connection['curl_options']['connection_timeout']; + $params['guzzleOptions']['curl.options'][CURLOPT_CONNECTTIMEOUT] = $connectionTimeout; + } + + if (!empty($connection['curl_options']) && !empty($connection['curl_options']['timeout'])) { + $timeout = $connection['curl_options']['timeout']; + $params['guzzleOptions']['curl.options'][CURLOPT_TIMEOUT] = $timeout; + } + if ($manager['debug']['enabled'] === true) { $params['logging'] = true; $params['logPath'] = $container->getParameter('es.logging.path'); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index c9d46e10..a48d4307 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -98,6 +98,18 @@ function ($value) { ->end() ->end() ->end() + ->arrayNode('curl_options') + ->children() + ->floatNode('connection_timeout') + ->defaultValue(2.0) + ->info('Sets the curl options for the connection timeout.') + ->end() + ->floatNode('timeout') + ->defaultValue(2.0) + ->info('Sets the curl options for the timeout.') + ->end() + ->end() + ->end() ->scalarNode('index_name') ->isRequired() ->info('Sets index name for connection.')