-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelasticsearch_client_2-3.patch
45 lines (43 loc) · 2.22 KB
/
elasticsearch_client_2-3.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
diff --git a/elasticsearch_connector.module b/elasticsearch_connector.module
index cbf16a5..37d32ab 100644
--- a/elasticsearch_connector.module
+++ b/elasticsearch_connector.module
@@ -792,15 +792,10 @@ function elasticsearch_connector_load_library($cluster) {
if (valid_url($cluster->url)) {
$options = array(
'hosts' => array($cluster->url),
- 'guzzleOptions' => array(
- 'curl.options' => array(
- CURLOPT_DNS_USE_GLOBAL_CACHE => TRUE,
- CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
- CURLOPT_CONNECTTIMEOUT => (!empty($cluster->options['timeout']) ? $cluster->options['timeout'] : ELASTICSEARCH_CONNECTOR_DEFAULT_TIMEOUT)
- )
- )
);
-
+ if (empty($cluster->options['timeout'])) {
+ $cluster->options['timeout'] = ELASTICSEARCH_CONNECTOR_DEFAULT_TIMEOUT;
+ }
if (!empty($cluster->options['use_authentication'])) {
$options['connectionParams'] = array(
'auth' => array($cluster->options['username'], $cluster->options['password'], $cluster->options['authentication_type']),
@@ -822,7 +817,11 @@ function elasticsearch_connector_load_library($cluster) {
drupal_alter('elasticsearch_connector_load_library_options', $options, $cluster);
- $clients[$cluster->cluster_id] = new \Elasticsearch\Client($options);
+ // Instantiate a new ClientBuilder
+ $clientBuilder = \Elasticsearch\ClientBuilder::create();
+ $clientBuilder->setHosts($options['hosts']);
+ // Build the client object
+ $clients[$cluster->cluster_id] = $clientBuilder->build();
}
catch (Exception $e) {
drupal_set_message($e->getMessage(), 'error');
@@ -878,7 +877,7 @@ function elasticsearch_connector_get_cluster_info($cluster, $enable_messages = F
$client = elasticsearch_connector_load_library($cluster);
if (!empty($client)) {
try {
- $info = $client->info();
+ $info = $client->info(array('client' => array('connect_timeout' => $cluster->options['timeout'])));
$result['client'] = $client;
$result['info'] = $result['state'] = $result['health'] = $result['stats'] = array();
if (elasticsearch_connector_check_status($info)) {