Skip to content
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'];
Comment thread
rbayet marked this conversation as 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
Copy Markdown
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">
Comment thread
rbayet marked this conversation as 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