Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-2011 - Set configuration for readtimeout and set timeout on ES … #2018

Open
wants to merge 2 commits into
base: 2.10.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ public function getHttpAuthPassword();
*/
public function getMaxParallelHandles();

/**
* Get the maximum number of seconds to wait for a response
*
* @return int
*/
public function getReadTimeout();

/**
* Client config options.
*
Expand Down
11 changes: 11 additions & 0 deletions src/module-elasticsuite-core/Client/ClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ public function build($options = [])
$clientBuilder->setSelector($selector);
}

$connectionParams = ['client' => []];
if (isset($options['timeout'])) {
$connectionParams['client']['timeout'] = $options['timeout'];
rbayet marked this conversation as resolved.
Show resolved Hide resolved
}
if (isset($options['connection_timeout'])) {
$connectionParams['client']['connect_timeout'] = $options['connection_timeout'];
}
if (count($connectionParams['client'])) {
$clientBuilder->setConnectionParams($connectionParams);
}

return $clientBuilder->build();
}

Expand Down
10 changes: 10 additions & 0 deletions src/module-elasticsuite-core/Client/ClientConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ public function getMaxParallelHandles()
return (int) $this->getElasticsearchClientConfigParam('max_parallel_handles');
}

/**
* {@inheritdoc}
*/
public function getReadTimeout()
{
return (int) $this->getElasticsearchClientConfigParam('timeout');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change param name to 'read_timeout' here if we change it in the system.xml ?

}

/**
* {@inheritDoc}
*/
Expand All @@ -125,6 +133,8 @@ public function getOptions()
'http_auth_pwd' => $this->getHttpAuthPassword(),
'is_debug_mode_enabled' => $this->isDebugModeEnabled(),
'max_parallel_handles' => $this->getMaxParallelHandles(),
'timeout' => $this->getReadTimeout(),
'connection_timeout' => $this->getConnectionTimeout(),
];

return $options;
Expand Down
5 changes: 5 additions & 0 deletions src/module-elasticsuite-core/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
<comment>In seconds.</comment>
<frontend_class>validate-number</frontend_class>
</field>
<field id="timeout" translate="label comment" type="text" sortOrder="57" showInDefault="1" showInWebsite="0" showInStore="0">
rbayet marked this conversation as resolved.
Show resolved Hide resolved
<label>Read Timeout</label>
<comment>In seconds.</comment>
<frontend_class>validate-number</frontend_class>
</field>
</group>

<group id="indices_settings" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down