@elastic/elasticsearch 6.8.4 → 6.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +10 -2
- package/api/api/bulk.js +18 -3
- package/api/api/cat.aliases.js +18 -3
- package/api/api/cat.allocation.js +18 -3
- package/api/api/cat.count.js +18 -3
- package/api/api/cat.fielddata.js +18 -3
- package/api/api/cat.health.js +18 -3
- package/api/api/cat.help.js +18 -3
- package/api/api/cat.indices.js +18 -3
- package/api/api/cat.master.js +18 -3
- package/api/api/cat.nodeattrs.js +18 -3
- package/api/api/cat.nodes.js +18 -3
- package/api/api/cat.pending_tasks.js +18 -3
- package/api/api/cat.plugins.js +18 -3
- package/api/api/cat.recovery.js +18 -3
- package/api/api/cat.repositories.js +18 -3
- package/api/api/cat.segments.js +18 -3
- package/api/api/cat.shards.js +18 -3
- package/api/api/cat.snapshots.js +18 -3
- package/api/api/cat.tasks.js +18 -3
- package/api/api/cat.templates.js +18 -3
- package/api/api/cat.thread_pool.js +18 -3
- package/api/api/ccr.delete_auto_follow_pattern.js +18 -3
- package/api/api/ccr.follow.js +18 -3
- package/api/api/ccr.follow_info.js +18 -3
- package/api/api/ccr.follow_stats.js +18 -3
- package/api/api/ccr.forget_follower.js +18 -3
- package/api/api/ccr.get_auto_follow_pattern.js +18 -3
- package/api/api/ccr.pause_follow.js +18 -3
- package/api/api/ccr.put_auto_follow_pattern.js +18 -3
- package/api/api/ccr.resume_follow.js +18 -3
- package/api/api/ccr.stats.js +18 -3
- package/api/api/ccr.unfollow.js +18 -3
- package/api/api/clear_scroll.js +18 -3
- package/api/api/cluster.allocation_explain.js +18 -3
- package/api/api/cluster.get_settings.js +18 -3
- package/api/api/cluster.health.js +18 -3
- package/api/api/cluster.pending_tasks.js +18 -3
- package/api/api/cluster.put_settings.js +18 -3
- package/api/api/cluster.remote_info.js +18 -3
- package/api/api/cluster.reroute.js +18 -3
- package/api/api/cluster.state.js +18 -3
- package/api/api/cluster.stats.js +18 -3
- package/api/api/count.js +18 -3
- package/api/api/create.js +18 -3
- package/api/api/delete.js +18 -3
- package/api/api/delete_by_query.js +18 -3
- package/api/api/delete_by_query_rethrottle.js +18 -3
- package/api/api/delete_script.js +18 -3
- package/api/api/exists.js +18 -3
- package/api/api/exists_source.js +18 -3
- package/api/api/explain.js +18 -3
- package/api/api/field_caps.js +18 -3
- package/api/api/get.js +18 -3
- package/api/api/get_script.js +18 -3
- package/api/api/get_source.js +18 -3
- package/api/api/ilm.delete_lifecycle.js +18 -3
- package/api/api/ilm.explain_lifecycle.js +18 -3
- package/api/api/ilm.get_lifecycle.js +18 -3
- package/api/api/ilm.get_status.js +18 -3
- package/api/api/ilm.move_to_step.js +18 -3
- package/api/api/ilm.put_lifecycle.js +18 -3
- package/api/api/ilm.remove_policy.js +18 -3
- package/api/api/ilm.retry.js +18 -3
- package/api/api/ilm.start.js +18 -3
- package/api/api/ilm.stop.js +18 -3
- package/api/api/index.js +18 -3
- package/api/api/indices.analyze.js +18 -3
- package/api/api/indices.clear_cache.js +18 -3
- package/api/api/indices.close.js +18 -3
- package/api/api/indices.create.js +18 -3
- package/api/api/indices.delete.js +18 -3
- package/api/api/indices.delete_alias.js +18 -3
- package/api/api/indices.delete_template.js +18 -3
- package/api/api/indices.exists.js +18 -3
- package/api/api/indices.exists_alias.js +18 -3
- package/api/api/indices.exists_template.js +18 -3
- package/api/api/indices.exists_type.js +18 -3
- package/api/api/indices.flush.js +18 -3
- package/api/api/indices.flush_synced.js +18 -3
- package/api/api/indices.forcemerge.js +18 -3
- package/api/api/indices.freeze.js +18 -3
- package/api/api/indices.get.js +18 -3
- package/api/api/indices.get_alias.js +18 -3
- package/api/api/indices.get_field_mapping.js +18 -3
- package/api/api/indices.get_mapping.js +18 -3
- package/api/api/indices.get_settings.js +18 -3
- package/api/api/indices.get_template.js +18 -3
- package/api/api/indices.get_upgrade.js +18 -3
- package/api/api/indices.open.js +18 -3
- package/api/api/indices.put_alias.js +18 -3
- package/api/api/indices.put_mapping.js +18 -3
- package/api/api/indices.put_settings.js +18 -3
- package/api/api/indices.put_template.js +18 -3
- package/api/api/indices.recovery.js +18 -3
- package/api/api/indices.refresh.js +18 -3
- package/api/api/indices.rollover.js +18 -3
- package/api/api/indices.segments.js +18 -3
- package/api/api/indices.shard_stores.js +18 -3
- package/api/api/indices.shrink.js +18 -3
- package/api/api/indices.split.js +18 -3
- package/api/api/indices.stats.js +18 -3
- package/api/api/indices.unfreeze.js +18 -3
- package/api/api/indices.update_aliases.js +18 -3
- package/api/api/indices.upgrade.js +18 -3
- package/api/api/indices.validate_query.js +18 -3
- package/api/api/info.js +18 -3
- package/api/api/ingest.delete_pipeline.js +18 -3
- package/api/api/ingest.get_pipeline.js +18 -3
- package/api/api/ingest.processor_grok.js +18 -3
- package/api/api/ingest.put_pipeline.js +18 -3
- package/api/api/ingest.simulate.js +18 -3
- package/api/api/mget.js +18 -3
- package/api/api/msearch.js +18 -3
- package/api/api/msearch_template.js +18 -3
- package/api/api/mtermvectors.js +18 -3
- package/api/api/nodes.hot_threads.js +18 -3
- package/api/api/nodes.info.js +18 -3
- package/api/api/nodes.reload_secure_settings.js +18 -3
- package/api/api/nodes.stats.js +18 -3
- package/api/api/nodes.usage.js +18 -3
- package/api/api/ping.js +18 -3
- package/api/api/put_script.js +18 -3
- package/api/api/rank_eval.js +18 -3
- package/api/api/reindex.js +18 -3
- package/api/api/reindex_rethrottle.js +18 -3
- package/api/api/render_search_template.js +18 -3
- package/api/api/scripts_painless_execute.js +18 -3
- package/api/api/scroll.js +18 -3
- package/api/api/search.js +18 -3
- package/api/api/search_shards.js +18 -3
- package/api/api/search_template.js +18 -3
- package/api/api/security.create_api_key.js +18 -3
- package/api/api/security.get_api_key.js +18 -3
- package/api/api/security.invalidate_api_key.js +18 -3
- package/api/api/snapshot.create.js +18 -3
- package/api/api/snapshot.create_repository.js +18 -3
- package/api/api/snapshot.delete.js +18 -3
- package/api/api/snapshot.delete_repository.js +18 -3
- package/api/api/snapshot.get.js +18 -3
- package/api/api/snapshot.get_repository.js +18 -3
- package/api/api/snapshot.restore.js +18 -3
- package/api/api/snapshot.status.js +18 -3
- package/api/api/snapshot.verify_repository.js +18 -3
- package/api/api/tasks.cancel.js +18 -3
- package/api/api/tasks.get.js +18 -3
- package/api/api/tasks.list.js +18 -3
- package/api/api/termvectors.js +18 -3
- package/api/api/update.js +18 -3
- package/api/api/update_by_query.js +18 -3
- package/api/api/update_by_query_rethrottle.js +18 -3
- package/api/api/xpack.graph.explore.js +18 -3
- package/api/api/xpack.info.js +18 -3
- package/api/api/xpack.license.delete.js +18 -3
- package/api/api/xpack.license.get.js +18 -3
- package/api/api/xpack.license.get_basic_status.js +18 -3
- package/api/api/xpack.license.get_trial_status.js +18 -3
- package/api/api/xpack.license.post.js +18 -3
- package/api/api/xpack.license.post_start_basic.js +18 -3
- package/api/api/xpack.license.post_start_trial.js +18 -3
- package/api/api/xpack.migration.deprecations.js +18 -3
- package/api/api/xpack.migration.get_assistance.js +18 -3
- package/api/api/xpack.migration.upgrade.js +18 -3
- package/api/api/xpack.ml.close_job.js +18 -3
- package/api/api/xpack.ml.delete_calendar.js +18 -3
- package/api/api/xpack.ml.delete_calendar_event.js +18 -3
- package/api/api/xpack.ml.delete_calendar_job.js +18 -3
- package/api/api/xpack.ml.delete_datafeed.js +18 -3
- package/api/api/xpack.ml.delete_expired_data.js +18 -3
- package/api/api/xpack.ml.delete_filter.js +18 -3
- package/api/api/xpack.ml.delete_forecast.js +18 -3
- package/api/api/xpack.ml.delete_job.js +18 -3
- package/api/api/xpack.ml.delete_model_snapshot.js +18 -3
- package/api/api/xpack.ml.find_file_structure.js +18 -3
- package/api/api/xpack.ml.flush_job.js +18 -3
- package/api/api/xpack.ml.forecast.js +18 -3
- package/api/api/xpack.ml.get_buckets.js +18 -3
- package/api/api/xpack.ml.get_calendar_events.js +18 -3
- package/api/api/xpack.ml.get_calendars.js +18 -3
- package/api/api/xpack.ml.get_categories.js +18 -3
- package/api/api/xpack.ml.get_datafeed_stats.js +18 -3
- package/api/api/xpack.ml.get_datafeeds.js +18 -3
- package/api/api/xpack.ml.get_filters.js +18 -3
- package/api/api/xpack.ml.get_influencers.js +18 -3
- package/api/api/xpack.ml.get_job_stats.js +18 -3
- package/api/api/xpack.ml.get_jobs.js +18 -3
- package/api/api/xpack.ml.get_model_snapshots.js +18 -3
- package/api/api/xpack.ml.get_overall_buckets.js +18 -3
- package/api/api/xpack.ml.get_records.js +18 -3
- package/api/api/xpack.ml.info.js +18 -3
- package/api/api/xpack.ml.open_job.js +18 -3
- package/api/api/xpack.ml.post_calendar_events.js +18 -3
- package/api/api/xpack.ml.post_data.js +18 -3
- package/api/api/xpack.ml.preview_datafeed.js +18 -3
- package/api/api/xpack.ml.put_calendar.js +18 -3
- package/api/api/xpack.ml.put_calendar_job.js +18 -3
- package/api/api/xpack.ml.put_datafeed.js +18 -3
- package/api/api/xpack.ml.put_filter.js +18 -3
- package/api/api/xpack.ml.put_job.js +18 -3
- package/api/api/xpack.ml.revert_model_snapshot.js +18 -3
- package/api/api/xpack.ml.set_upgrade_mode.js +18 -3
- package/api/api/xpack.ml.start_datafeed.js +18 -3
- package/api/api/xpack.ml.stop_datafeed.js +18 -3
- package/api/api/xpack.ml.update_datafeed.js +18 -3
- package/api/api/xpack.ml.update_filter.js +18 -3
- package/api/api/xpack.ml.update_job.js +18 -3
- package/api/api/xpack.ml.update_model_snapshot.js +18 -3
- package/api/api/xpack.ml.validate.js +18 -3
- package/api/api/xpack.ml.validate_detector.js +18 -3
- package/api/api/xpack.monitoring.bulk.js +18 -3
- package/api/api/xpack.rollup.delete_job.js +18 -3
- package/api/api/xpack.rollup.get_jobs.js +18 -3
- package/api/api/xpack.rollup.get_rollup_caps.js +18 -3
- package/api/api/xpack.rollup.get_rollup_index_caps.js +18 -3
- package/api/api/xpack.rollup.put_job.js +18 -3
- package/api/api/xpack.rollup.rollup_search.js +18 -3
- package/api/api/xpack.rollup.start_job.js +18 -3
- package/api/api/xpack.rollup.stop_job.js +18 -3
- package/api/api/xpack.security.authenticate.js +18 -3
- package/api/api/xpack.security.change_password.js +18 -3
- package/api/api/xpack.security.clear_cached_realms.js +18 -3
- package/api/api/xpack.security.clear_cached_roles.js +18 -3
- package/api/api/xpack.security.delete_privileges.js +18 -3
- package/api/api/xpack.security.delete_role.js +18 -3
- package/api/api/xpack.security.delete_role_mapping.js +18 -3
- package/api/api/xpack.security.delete_user.js +18 -3
- package/api/api/xpack.security.disable_user.js +18 -3
- package/api/api/xpack.security.enable_user.js +18 -3
- package/api/api/xpack.security.get_privileges.js +18 -3
- package/api/api/xpack.security.get_role.js +18 -3
- package/api/api/xpack.security.get_role_mapping.js +18 -3
- package/api/api/xpack.security.get_token.js +18 -3
- package/api/api/xpack.security.get_user.js +18 -3
- package/api/api/xpack.security.get_user_privileges.js +18 -3
- package/api/api/xpack.security.has_privileges.js +18 -3
- package/api/api/xpack.security.invalidate_token.js +18 -3
- package/api/api/xpack.security.put_privileges.js +18 -3
- package/api/api/xpack.security.put_role.js +18 -3
- package/api/api/xpack.security.put_role_mapping.js +18 -3
- package/api/api/xpack.security.put_user.js +18 -3
- package/api/api/xpack.sql.clear_cursor.js +18 -3
- package/api/api/xpack.sql.query.js +18 -3
- package/api/api/xpack.sql.translate.js +18 -3
- package/api/api/xpack.ssl.certificates.js +18 -3
- package/api/api/xpack.usage.js +18 -3
- package/api/api/xpack.watcher.ack_watch.js +18 -3
- package/api/api/xpack.watcher.activate_watch.js +18 -3
- package/api/api/xpack.watcher.deactivate_watch.js +18 -3
- package/api/api/xpack.watcher.delete_watch.js +18 -3
- package/api/api/xpack.watcher.execute_watch.js +18 -3
- package/api/api/xpack.watcher.get_watch.js +18 -3
- package/api/api/xpack.watcher.put_watch.js +18 -3
- package/api/api/xpack.watcher.restart.js +18 -3
- package/api/api/xpack.watcher.start.js +18 -3
- package/api/api/xpack.watcher.stats.js +18 -3
- package/api/api/xpack.watcher.stop.js +18 -3
- package/api/index.js +18 -3
- package/api/requestParams.d.ts +18 -3
- package/{.codecov.yml → codecov.yml} +1 -1
- package/index.d.ts +20 -5
- package/index.js +18 -3
- package/lib/Connection.d.ts +18 -3
- package/lib/Connection.js +20 -7
- package/lib/Serializer.d.ts +18 -3
- package/lib/Serializer.js +20 -4
- package/lib/Transport.d.ts +19 -4
- package/lib/Transport.js +29 -13
- package/lib/errors.d.ts +18 -3
- package/lib/errors.js +19 -4
- package/lib/pool/BaseConnectionPool.js +21 -6
- package/lib/pool/CloudConnectionPool.js +18 -3
- package/lib/pool/ConnectionPool.js +34 -19
- package/lib/pool/index.d.ts +19 -4
- package/lib/pool/index.js +18 -3
- package/package.json +4 -5
package/lib/Serializer.js
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
3
|
+
* license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright
|
|
5
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
6
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
7
|
+
* not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
4
19
|
|
|
5
20
|
'use strict'
|
|
6
21
|
|
|
7
22
|
const { stringify } = require('querystring')
|
|
8
23
|
const debug = require('debug')('elasticsearch')
|
|
24
|
+
const sjson = require('secure-json-parse')
|
|
9
25
|
const { SerializationError, DeserializationError } = require('./errors')
|
|
10
26
|
|
|
11
27
|
class Serializer {
|
|
@@ -22,7 +38,7 @@ class Serializer {
|
|
|
22
38
|
deserialize (json) {
|
|
23
39
|
debug('Deserializing', json)
|
|
24
40
|
try {
|
|
25
|
-
var object =
|
|
41
|
+
var object = sjson.parse(json)
|
|
26
42
|
} catch (err) {
|
|
27
43
|
throw new DeserializationError(err.message)
|
|
28
44
|
}
|
package/lib/Transport.d.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
3
|
+
* license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright
|
|
5
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
6
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
7
|
+
* not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
4
19
|
|
|
5
20
|
import { ConnectionPool, CloudConnectionPool } from './pool';
|
|
6
21
|
import Connection from './Connection';
|
|
@@ -81,7 +96,7 @@ export interface TransportRequestParams {
|
|
|
81
96
|
}
|
|
82
97
|
|
|
83
98
|
export interface TransportRequestOptions {
|
|
84
|
-
ignore?: [
|
|
99
|
+
ignore?: number[];
|
|
85
100
|
requestTimeout?: number | string;
|
|
86
101
|
maxRetries?: number;
|
|
87
102
|
asStream?: boolean;
|
package/lib/Transport.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
3
|
+
* license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright
|
|
5
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
6
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
7
|
+
* not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
4
19
|
|
|
5
20
|
'use strict'
|
|
6
21
|
|
|
@@ -108,10 +123,9 @@ class Transport {
|
|
|
108
123
|
const makeRequest = () => {
|
|
109
124
|
if (meta.aborted === true) return
|
|
110
125
|
meta.connection = this.getConnection({ requestId: meta.request.id })
|
|
111
|
-
if (meta.connection
|
|
112
|
-
return callback(new NoLivingConnectionsError(
|
|
126
|
+
if (meta.connection == null) {
|
|
127
|
+
return callback(new NoLivingConnectionsError(), result)
|
|
113
128
|
}
|
|
114
|
-
|
|
115
129
|
// TODO: make this assignment FAST
|
|
116
130
|
const headers = Object.assign({}, this.headers, options.headers)
|
|
117
131
|
|
|
@@ -130,15 +144,17 @@ class Transport {
|
|
|
130
144
|
return callback(err, result)
|
|
131
145
|
}
|
|
132
146
|
}
|
|
133
|
-
headers['Content-Type'] = headers['Content-Type'] || 'application/json'
|
|
134
147
|
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
148
|
+
if (params.body !== '') {
|
|
149
|
+
headers['Content-Type'] = headers['Content-Type'] || 'application/json'
|
|
150
|
+
if (compression === 'gzip') {
|
|
151
|
+
if (isStream(params.body) === false) {
|
|
152
|
+
params.body = intoStream(params.body).pipe(createGzip())
|
|
153
|
+
} else {
|
|
154
|
+
params.body = params.body.pipe(createGzip())
|
|
155
|
+
}
|
|
156
|
+
headers['Content-Encoding'] = compression
|
|
140
157
|
}
|
|
141
|
-
headers['Content-Encoding'] = compression
|
|
142
158
|
}
|
|
143
159
|
|
|
144
160
|
if (isStream(params.body) === false) {
|
package/lib/errors.d.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
3
|
+
* license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright
|
|
5
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
6
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
7
|
+
* not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
4
19
|
|
|
5
20
|
import { ApiResponse } from './Transport'
|
|
6
21
|
|
package/lib/errors.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
3
|
+
* license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright
|
|
5
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
6
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
7
|
+
* not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
4
19
|
|
|
5
20
|
'use strict'
|
|
6
21
|
|
|
@@ -36,7 +51,7 @@ class NoLivingConnectionsError extends ElasticsearchClientError {
|
|
|
36
51
|
super(message)
|
|
37
52
|
Error.captureStackTrace(this, NoLivingConnectionsError)
|
|
38
53
|
this.name = 'NoLivingConnectionsError'
|
|
39
|
-
this.message = message || '
|
|
54
|
+
this.message = message || 'Given the configuration, the ConnectionPool was not able to find a usable Connection for this request.'
|
|
40
55
|
this.meta = meta
|
|
41
56
|
}
|
|
42
57
|
}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
3
|
+
* license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright
|
|
5
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
6
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
7
|
+
* not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
4
19
|
|
|
5
20
|
'use strict'
|
|
6
21
|
|
|
@@ -42,13 +57,13 @@ class BaseConnectionPool {
|
|
|
42
57
|
opts = this.urlToHost(opts)
|
|
43
58
|
}
|
|
44
59
|
|
|
45
|
-
if (
|
|
60
|
+
if (this.auth !== null) {
|
|
61
|
+
opts.auth = this.auth
|
|
62
|
+
} else if (opts.url.username !== '' && opts.url.password !== '') {
|
|
46
63
|
opts.auth = {
|
|
47
64
|
username: decodeURIComponent(opts.url.username),
|
|
48
65
|
password: decodeURIComponent(opts.url.password)
|
|
49
66
|
}
|
|
50
|
-
} else if (this.auth !== null) {
|
|
51
|
-
opts.auth = this.auth
|
|
52
67
|
}
|
|
53
68
|
|
|
54
69
|
if (opts.ssl == null) opts.ssl = this._ssl
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
3
|
+
* license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright
|
|
5
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
6
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
7
|
+
* not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
4
19
|
|
|
5
20
|
'use strict'
|
|
6
21
|
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
3
|
+
* license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright
|
|
5
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
6
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
7
|
+
* not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
4
19
|
|
|
5
20
|
'use strict'
|
|
6
21
|
|
|
@@ -35,13 +50,10 @@ class ConnectionPool extends BaseConnectionPool {
|
|
|
35
50
|
* Marks a connection as 'alive'.
|
|
36
51
|
* If needed removes the connection from the dead list
|
|
37
52
|
* and then resets the `deadCount`.
|
|
38
|
-
* If sniffing is not enabled and there is only
|
|
39
|
-
* one node, this method is a noop.
|
|
40
53
|
*
|
|
41
54
|
* @param {object} connection
|
|
42
55
|
*/
|
|
43
56
|
markAlive (connection) {
|
|
44
|
-
if (this._sniffEnabled === false && this.size === 1) return this
|
|
45
57
|
const { id } = connection
|
|
46
58
|
debug(`Marking as 'alive' connection '${id}'`)
|
|
47
59
|
const index = this.dead.indexOf(id)
|
|
@@ -56,17 +68,24 @@ class ConnectionPool extends BaseConnectionPool {
|
|
|
56
68
|
* Marks a connection as 'dead'.
|
|
57
69
|
* If needed adds the connection to the dead list
|
|
58
70
|
* and then increments the `deadCount`.
|
|
59
|
-
* If sniffing is not enabled and there is only
|
|
60
|
-
* one node, this method is a noop.
|
|
61
71
|
*
|
|
62
72
|
* @param {object} connection
|
|
63
73
|
*/
|
|
64
74
|
markDead (connection) {
|
|
65
|
-
if (this._sniffEnabled === false && this.size === 1) return this
|
|
66
75
|
const { id } = connection
|
|
67
76
|
debug(`Marking as 'dead' connection '${id}'`)
|
|
68
77
|
if (this.dead.indexOf(id) === -1) {
|
|
69
|
-
|
|
78
|
+
// It might happen that `markDead` is called jsut after
|
|
79
|
+
// a pool update, and in such case we will add to the dead
|
|
80
|
+
// list a node that no longer exist. The following check verify
|
|
81
|
+
// that the connection is still part of the pool before
|
|
82
|
+
// marking it as dead.
|
|
83
|
+
for (var i = 0; i < this.size; i++) {
|
|
84
|
+
if (this.connections[i].id === id) {
|
|
85
|
+
this.dead.push(id)
|
|
86
|
+
break
|
|
87
|
+
}
|
|
88
|
+
}
|
|
70
89
|
}
|
|
71
90
|
connection.status = Connection.statuses.DEAD
|
|
72
91
|
connection.deadCount++
|
|
@@ -158,7 +177,7 @@ class ConnectionPool extends BaseConnectionPool {
|
|
|
158
177
|
|
|
159
178
|
/**
|
|
160
179
|
* Returns an alive connection if present,
|
|
161
|
-
* otherwise returns
|
|
180
|
+
* otherwise returns a dead connection.
|
|
162
181
|
* By default it filters the `master` only nodes.
|
|
163
182
|
* It uses the selector to choose which
|
|
164
183
|
* connection return.
|
|
@@ -176,11 +195,13 @@ class ConnectionPool extends BaseConnectionPool {
|
|
|
176
195
|
name: opts.name
|
|
177
196
|
})
|
|
178
197
|
|
|
198
|
+
const noAliveConnections = this.size === this.dead.length
|
|
199
|
+
|
|
179
200
|
// TODO: can we cache this?
|
|
180
201
|
const connections = []
|
|
181
202
|
for (var i = 0; i < this.size; i++) {
|
|
182
203
|
const connection = this.connections[i]
|
|
183
|
-
if (connection.status === Connection.statuses.ALIVE) {
|
|
204
|
+
if (noAliveConnections || connection.status === Connection.statuses.ALIVE) {
|
|
184
205
|
if (filter(connection) === true) {
|
|
185
206
|
connections.push(connection)
|
|
186
207
|
}
|
|
@@ -212,13 +233,7 @@ class ConnectionPool extends BaseConnectionPool {
|
|
|
212
233
|
*/
|
|
213
234
|
update (connections) {
|
|
214
235
|
super.update(connections)
|
|
215
|
-
|
|
216
|
-
for (var i = 0; i < this.dead.length; i++) {
|
|
217
|
-
if (this.connections.find(c => c.id === this.dead[i]) === undefined) {
|
|
218
|
-
this.dead.splice(i, 1)
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
236
|
+
this.dead = []
|
|
222
237
|
return this
|
|
223
238
|
}
|
|
224
239
|
}
|
package/lib/pool/index.d.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
3
|
+
* license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright
|
|
5
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
6
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
7
|
+
* not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
4
19
|
|
|
5
20
|
/// <reference types="node" />
|
|
6
21
|
|
|
@@ -88,7 +103,7 @@ declare class BaseConnectionPool {
|
|
|
88
103
|
markDead(connection: Connection): this;
|
|
89
104
|
/**
|
|
90
105
|
* Returns an alive connection if present,
|
|
91
|
-
* otherwise returns
|
|
106
|
+
* otherwise returns a dead connection.
|
|
92
107
|
* By default it filters the `master` only nodes.
|
|
93
108
|
* It uses the selector to choose which
|
|
94
109
|
* connection return.
|
package/lib/pool/index.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
3
|
+
* license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright
|
|
5
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
6
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
7
|
+
* not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
4
19
|
|
|
5
20
|
'use strict'
|
|
6
21
|
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html",
|
|
7
|
-
"version": "6.8.
|
|
7
|
+
"version": "6.8.8",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"elasticsearch",
|
|
10
10
|
"elastic",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"test:behavior": "tap test/behavior/*.test.js -t 300 --no-coverage",
|
|
22
22
|
"test:integration": "tap test/integration/index.js -T --no-coverage",
|
|
23
23
|
"test:types": "tsc --project ./test/types/tsconfig.json",
|
|
24
|
-
"test:coverage": "nyc tap test/unit/*.test.js test/behavior/*.test.js -t 300 && nyc report --reporter=text-lcov > coverage.lcov
|
|
24
|
+
"test:coverage": "nyc tap test/unit/*.test.js test/behavior/*.test.js -t 300 && nyc report --reporter=text-lcov > coverage.lcov",
|
|
25
25
|
"lint": "standard",
|
|
26
26
|
"lint:fix": "standard --fix",
|
|
27
27
|
"ci": "npm run license-checker && npm test && npm run test:integration && npm run test:coverage",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^12.6.2",
|
|
42
|
-
"codecov": "^3.3.0",
|
|
43
42
|
"convert-hrtime": "^3.0.0",
|
|
44
43
|
"dedent": "^0.7.0",
|
|
45
44
|
"deepmerge": "^4.0.0",
|
|
@@ -58,7 +57,6 @@
|
|
|
58
57
|
"standard": "^13.0.2",
|
|
59
58
|
"stoppable": "^1.1.0",
|
|
60
59
|
"tap": "^14.4.1",
|
|
61
|
-
"tap-mocha-reporter": "^4.0.1",
|
|
62
60
|
"typescript": "^3.4.5",
|
|
63
61
|
"workq": "^2.1.0"
|
|
64
62
|
},
|
|
@@ -68,7 +66,8 @@
|
|
|
68
66
|
"into-stream": "^5.1.0",
|
|
69
67
|
"ms": "^2.1.1",
|
|
70
68
|
"once": "^1.4.0",
|
|
71
|
-
"pump": "^3.0.0"
|
|
69
|
+
"pump": "^3.0.0",
|
|
70
|
+
"secure-json-parse": "^2.1.0"
|
|
72
71
|
},
|
|
73
72
|
"license": "Apache-2.0",
|
|
74
73
|
"repository": {
|