@elastic/elasticsearch 7.15.0
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/.dockerignore +5 -0
- package/LICENSE +202 -0
- package/README.md +232 -0
- package/api/api/async_search.js +141 -0
- package/api/api/autoscaling.js +147 -0
- package/api/api/bulk.js +70 -0
- package/api/api/cat.js +648 -0
- package/api/api/ccr.js +403 -0
- package/api/api/clear_scroll.js +55 -0
- package/api/api/close_point_in_time.js +50 -0
- package/api/api/cluster.js +420 -0
- package/api/api/count.js +64 -0
- package/api/api/create.js +69 -0
- package/api/api/dangling_indices.js +115 -0
- package/api/api/delete.js +65 -0
- package/api/api/delete_by_query.js +71 -0
- package/api/api/delete_by_query_rethrottle.js +60 -0
- package/api/api/delete_script.js +56 -0
- package/api/api/enrich.js +173 -0
- package/api/api/eql.js +150 -0
- package/api/api/exists.js +65 -0
- package/api/api/exists_source.js +74 -0
- package/api/api/explain.js +65 -0
- package/api/api/features.js +81 -0
- package/api/api/field_caps.js +55 -0
- package/api/api/fleet.js +65 -0
- package/api/api/get.js +65 -0
- package/api/api/get_script.js +56 -0
- package/api/api/get_script_context.js +50 -0
- package/api/api/get_script_languages.js +50 -0
- package/api/api/get_source.js +65 -0
- package/api/api/graph.js +72 -0
- package/api/api/ilm.js +317 -0
- package/api/api/index.js +71 -0
- package/api/api/indices.js +1753 -0
- package/api/api/info.js +50 -0
- package/api/api/ingest.js +200 -0
- package/api/api/license.js +188 -0
- package/api/api/logstash.js +125 -0
- package/api/api/mget.js +70 -0
- package/api/api/migration.js +60 -0
- package/api/api/ml.js +2010 -0
- package/api/api/monitoring.js +66 -0
- package/api/api/msearch.js +70 -0
- package/api/api/msearch_template.js +70 -0
- package/api/api/mtermvectors.js +64 -0
- package/api/api/nodes.js +268 -0
- package/api/api/open_point_in_time.js +56 -0
- package/api/api/ping.js +50 -0
- package/api/api/put_script.js +71 -0
- package/api/api/rank_eval.js +61 -0
- package/api/api/reindex.js +56 -0
- package/api/api/reindex_rethrottle.js +60 -0
- package/api/api/render_search_template.js +55 -0
- package/api/api/rollup.js +319 -0
- package/api/api/scripts_painless_execute.js +50 -0
- package/api/api/scroll.js +55 -0
- package/api/api/search.js +64 -0
- package/api/api/search_mvt.js +87 -0
- package/api/api/search_shards.js +55 -0
- package/api/api/search_template.js +70 -0
- package/api/api/searchable_snapshots.js +186 -0
- package/api/api/security.js +1261 -0
- package/api/api/shutdown.js +124 -0
- package/api/api/slm.js +256 -0
- package/api/api/snapshot.js +439 -0
- package/api/api/sql.js +203 -0
- package/api/api/ssl.js +55 -0
- package/api/api/tasks.js +108 -0
- package/api/api/terms_enum.js +56 -0
- package/api/api/termvectors.js +67 -0
- package/api/api/text_structure.js +65 -0
- package/api/api/transform.js +268 -0
- package/api/api/update.js +69 -0
- package/api/api/update_by_query.js +67 -0
- package/api/api/update_by_query_rethrottle.js +60 -0
- package/api/api/watcher.js +333 -0
- package/api/api/xpack.js +76 -0
- package/api/index.js +508 -0
- package/api/new.d.ts +1585 -0
- package/api/requestParams.d.ts +2920 -0
- package/api/types.d.ts +15420 -0
- package/api/utils.js +58 -0
- package/codecov.yml +14 -0
- package/index.d.ts +2991 -0
- package/index.js +349 -0
- package/index.mjs +29 -0
- package/lib/Connection.d.ts +99 -0
- package/lib/Connection.js +392 -0
- package/lib/Helpers.d.ts +124 -0
- package/lib/Helpers.js +770 -0
- package/lib/Serializer.d.ts +30 -0
- package/lib/Serializer.js +94 -0
- package/lib/Transport.d.ts +162 -0
- package/lib/Transport.js +689 -0
- package/lib/errors.d.ts +90 -0
- package/lib/errors.js +159 -0
- package/lib/pool/BaseConnectionPool.js +262 -0
- package/lib/pool/CloudConnectionPool.js +64 -0
- package/lib/pool/ConnectionPool.js +246 -0
- package/lib/pool/index.d.ts +220 -0
- package/lib/pool/index.js +30 -0
- package/package.json +106 -0
|
@@ -0,0 +1,246 @@
|
|
|
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
|
+
*/
|
|
19
|
+
|
|
20
|
+
'use strict'
|
|
21
|
+
|
|
22
|
+
const BaseConnectionPool = require('./BaseConnectionPool')
|
|
23
|
+
const assert = require('assert')
|
|
24
|
+
const debug = require('debug')('elasticsearch')
|
|
25
|
+
const Connection = require('../Connection')
|
|
26
|
+
const noop = () => {}
|
|
27
|
+
|
|
28
|
+
class ConnectionPool extends BaseConnectionPool {
|
|
29
|
+
constructor (opts) {
|
|
30
|
+
super(opts)
|
|
31
|
+
|
|
32
|
+
this.dead = []
|
|
33
|
+
// the resurrect timeout is 60s
|
|
34
|
+
this.resurrectTimeout = 1000 * 60
|
|
35
|
+
// number of consecutive failures after which
|
|
36
|
+
// the timeout doesn't increase
|
|
37
|
+
this.resurrectTimeoutCutoff = 5
|
|
38
|
+
this.pingTimeout = opts.pingTimeout
|
|
39
|
+
this._sniffEnabled = opts.sniffEnabled || false
|
|
40
|
+
|
|
41
|
+
const resurrectStrategy = opts.resurrectStrategy || 'ping'
|
|
42
|
+
this.resurrectStrategy = ConnectionPool.resurrectStrategies[resurrectStrategy]
|
|
43
|
+
assert(
|
|
44
|
+
this.resurrectStrategy != null,
|
|
45
|
+
`Invalid resurrection strategy: '${resurrectStrategy}'`
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Marks a connection as 'alive'.
|
|
51
|
+
* If needed removes the connection from the dead list
|
|
52
|
+
* and then resets the `deadCount`.
|
|
53
|
+
*
|
|
54
|
+
* @param {object} connection
|
|
55
|
+
*/
|
|
56
|
+
markAlive (connection) {
|
|
57
|
+
const { id } = connection
|
|
58
|
+
debug(`Marking as 'alive' connection '${id}'`)
|
|
59
|
+
const index = this.dead.indexOf(id)
|
|
60
|
+
if (index > -1) this.dead.splice(index, 1)
|
|
61
|
+
connection.status = Connection.statuses.ALIVE
|
|
62
|
+
connection.deadCount = 0
|
|
63
|
+
connection.resurrectTimeout = 0
|
|
64
|
+
return this
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Marks a connection as 'dead'.
|
|
69
|
+
* If needed adds the connection to the dead list
|
|
70
|
+
* and then increments the `deadCount`.
|
|
71
|
+
*
|
|
72
|
+
* @param {object} connection
|
|
73
|
+
*/
|
|
74
|
+
markDead (connection) {
|
|
75
|
+
const { id } = connection
|
|
76
|
+
debug(`Marking as 'dead' connection '${id}'`)
|
|
77
|
+
if (this.dead.indexOf(id) === -1) {
|
|
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 (let i = 0; i < this.size; i++) {
|
|
84
|
+
if (this.connections[i].id === id) {
|
|
85
|
+
this.dead.push(id)
|
|
86
|
+
break
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
connection.status = Connection.statuses.DEAD
|
|
91
|
+
connection.deadCount++
|
|
92
|
+
// resurrectTimeout formula:
|
|
93
|
+
// `resurrectTimeout * 2 ** min(deadCount - 1, resurrectTimeoutCutoff)`
|
|
94
|
+
connection.resurrectTimeout = Date.now() + this.resurrectTimeout * Math.pow(
|
|
95
|
+
2, Math.min(connection.deadCount - 1, this.resurrectTimeoutCutoff)
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
// sort the dead list in ascending order
|
|
99
|
+
// based on the resurrectTimeout
|
|
100
|
+
this.dead.sort((a, b) => {
|
|
101
|
+
const conn1 = this.connections.find(c => c.id === a)
|
|
102
|
+
const conn2 = this.connections.find(c => c.id === b)
|
|
103
|
+
return conn1.resurrectTimeout - conn2.resurrectTimeout
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
return this
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* If enabled, tries to resurrect a connection with the given
|
|
111
|
+
* resurrect strategy ('ping', 'optimistic', 'none').
|
|
112
|
+
*
|
|
113
|
+
* @param {object} { now, requestId }
|
|
114
|
+
* @param {function} callback (isAlive, connection)
|
|
115
|
+
*/
|
|
116
|
+
resurrect (opts, callback = noop) {
|
|
117
|
+
if (this.resurrectStrategy === 0 || this.dead.length === 0) {
|
|
118
|
+
debug('Nothing to resurrect')
|
|
119
|
+
callback(null, null)
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// the dead list is sorted in ascending order based on the timeout
|
|
124
|
+
// so the first element will always be the one with the smaller timeout
|
|
125
|
+
const connection = this.connections.find(c => c.id === this.dead[0])
|
|
126
|
+
if ((opts.now || Date.now()) < connection.resurrectTimeout) {
|
|
127
|
+
debug('Nothing to resurrect')
|
|
128
|
+
callback(null, null)
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const { id } = connection
|
|
133
|
+
|
|
134
|
+
// ping strategy
|
|
135
|
+
if (this.resurrectStrategy === 1) {
|
|
136
|
+
connection.request({
|
|
137
|
+
method: 'HEAD',
|
|
138
|
+
path: '/',
|
|
139
|
+
timeout: this.pingTimeout
|
|
140
|
+
}, (err, response) => {
|
|
141
|
+
let isAlive = true
|
|
142
|
+
const statusCode = response !== null ? response.statusCode : 0
|
|
143
|
+
if (err != null ||
|
|
144
|
+
(statusCode === 502 || statusCode === 503 || statusCode === 504)) {
|
|
145
|
+
debug(`Resurrect: connection '${id}' is still dead`)
|
|
146
|
+
this.markDead(connection)
|
|
147
|
+
isAlive = false
|
|
148
|
+
} else {
|
|
149
|
+
debug(`Resurrect: connection '${id}' is now alive`)
|
|
150
|
+
this.markAlive(connection)
|
|
151
|
+
}
|
|
152
|
+
this.emit('resurrect', null, {
|
|
153
|
+
strategy: 'ping',
|
|
154
|
+
name: opts.name,
|
|
155
|
+
request: { id: opts.requestId },
|
|
156
|
+
isAlive,
|
|
157
|
+
connection
|
|
158
|
+
})
|
|
159
|
+
callback(isAlive, connection)
|
|
160
|
+
})
|
|
161
|
+
// optimistic strategy
|
|
162
|
+
} else {
|
|
163
|
+
debug(`Resurrect: optimistic resurrection for connection '${id}'`)
|
|
164
|
+
this.dead.splice(this.dead.indexOf(id), 1)
|
|
165
|
+
connection.status = Connection.statuses.ALIVE
|
|
166
|
+
this.emit('resurrect', null, {
|
|
167
|
+
strategy: 'optimistic',
|
|
168
|
+
name: opts.name,
|
|
169
|
+
request: { id: opts.requestId },
|
|
170
|
+
isAlive: true,
|
|
171
|
+
connection
|
|
172
|
+
})
|
|
173
|
+
callback(true, connection) // eslint-disable-line
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Returns an alive connection if present,
|
|
179
|
+
* otherwise returns a dead connection.
|
|
180
|
+
* By default it filters the `master` only nodes.
|
|
181
|
+
* It uses the selector to choose which
|
|
182
|
+
* connection return.
|
|
183
|
+
*
|
|
184
|
+
* @param {object} options (filter and selector)
|
|
185
|
+
* @returns {object|null} connection
|
|
186
|
+
*/
|
|
187
|
+
getConnection (opts = {}) {
|
|
188
|
+
const filter = opts.filter || (() => true)
|
|
189
|
+
const selector = opts.selector || (c => c[0])
|
|
190
|
+
|
|
191
|
+
this.resurrect({
|
|
192
|
+
now: opts.now,
|
|
193
|
+
requestId: opts.requestId,
|
|
194
|
+
name: opts.name
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
const noAliveConnections = this.size === this.dead.length
|
|
198
|
+
|
|
199
|
+
// TODO: can we cache this?
|
|
200
|
+
const connections = []
|
|
201
|
+
for (let i = 0; i < this.size; i++) {
|
|
202
|
+
const connection = this.connections[i]
|
|
203
|
+
if (noAliveConnections || connection.status === Connection.statuses.ALIVE) {
|
|
204
|
+
if (filter(connection) === true) {
|
|
205
|
+
connections.push(connection)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (connections.length === 0) return null
|
|
211
|
+
|
|
212
|
+
return selector(connections)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Empties the connection pool.
|
|
217
|
+
*
|
|
218
|
+
* @returns {ConnectionPool}
|
|
219
|
+
*/
|
|
220
|
+
empty (callback) {
|
|
221
|
+
super.empty(() => {
|
|
222
|
+
this.dead = []
|
|
223
|
+
callback()
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Update the ConnectionPool with new connections.
|
|
229
|
+
*
|
|
230
|
+
* @param {array} array of connections
|
|
231
|
+
* @returns {ConnectionPool}
|
|
232
|
+
*/
|
|
233
|
+
update (connections) {
|
|
234
|
+
super.update(connections)
|
|
235
|
+
this.dead = []
|
|
236
|
+
return this
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
ConnectionPool.resurrectStrategies = {
|
|
241
|
+
none: 0,
|
|
242
|
+
ping: 1,
|
|
243
|
+
optimistic: 2
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
module.exports = ConnectionPool
|
|
@@ -0,0 +1,220 @@
|
|
|
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
|
+
*/
|
|
19
|
+
|
|
20
|
+
/// <reference types="node" />
|
|
21
|
+
|
|
22
|
+
import { URL } from 'url'
|
|
23
|
+
import { SecureContextOptions } from 'tls';
|
|
24
|
+
import Connection, { AgentOptions } from '../Connection';
|
|
25
|
+
import { nodeFilterFn, nodeSelectorFn } from '../Transport';
|
|
26
|
+
|
|
27
|
+
interface BaseConnectionPoolOptions {
|
|
28
|
+
ssl?: SecureContextOptions;
|
|
29
|
+
agent?: AgentOptions;
|
|
30
|
+
proxy?: string | URL;
|
|
31
|
+
auth?: BasicAuth | ApiKeyAuth;
|
|
32
|
+
emit: (event: string | symbol, ...args: any[]) => boolean;
|
|
33
|
+
Connection: typeof Connection;
|
|
34
|
+
caFingerprint?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface ConnectionPoolOptions extends BaseConnectionPoolOptions {
|
|
38
|
+
pingTimeout?: number;
|
|
39
|
+
resurrectStrategy?: 'ping' | 'optimistic' | 'none';
|
|
40
|
+
sniffEnabled?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface getConnectionOptions {
|
|
44
|
+
filter?: nodeFilterFn;
|
|
45
|
+
selector?: nodeSelectorFn;
|
|
46
|
+
requestId?: string | number;
|
|
47
|
+
name?: string;
|
|
48
|
+
now?: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface ApiKeyAuth {
|
|
52
|
+
apiKey:
|
|
53
|
+
| string
|
|
54
|
+
| {
|
|
55
|
+
id: string;
|
|
56
|
+
api_key: string;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface BasicAuth {
|
|
61
|
+
username: string;
|
|
62
|
+
password: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface BearerAuth {
|
|
66
|
+
bearer: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface resurrectOptions {
|
|
70
|
+
now?: number;
|
|
71
|
+
requestId: string;
|
|
72
|
+
name: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface ResurrectEvent {
|
|
76
|
+
strategy: string;
|
|
77
|
+
isAlive: boolean;
|
|
78
|
+
connection: Connection;
|
|
79
|
+
name: string;
|
|
80
|
+
request: {
|
|
81
|
+
id: any;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
declare class BaseConnectionPool {
|
|
87
|
+
connections: Connection[];
|
|
88
|
+
size: number;
|
|
89
|
+
emit: (event: string | symbol, ...args: any[]) => boolean;
|
|
90
|
+
_ssl: SecureContextOptions | null;
|
|
91
|
+
_agent: AgentOptions | null;
|
|
92
|
+
_proxy: string | URL;
|
|
93
|
+
auth: BasicAuth | ApiKeyAuth;
|
|
94
|
+
Connection: typeof Connection;
|
|
95
|
+
constructor(opts?: BaseConnectionPoolOptions);
|
|
96
|
+
/**
|
|
97
|
+
* Marks a connection as 'alive'.
|
|
98
|
+
* If needed removes the connection from the dead list
|
|
99
|
+
* and then resets the `deadCount`.
|
|
100
|
+
*
|
|
101
|
+
* @param {object} connection
|
|
102
|
+
*/
|
|
103
|
+
markAlive(connection: Connection): this;
|
|
104
|
+
/**
|
|
105
|
+
* Marks a connection as 'dead'.
|
|
106
|
+
* If needed adds the connection to the dead list
|
|
107
|
+
* and then increments the `deadCount`.
|
|
108
|
+
*
|
|
109
|
+
* @param {object} connection
|
|
110
|
+
*/
|
|
111
|
+
markDead(connection: Connection): this;
|
|
112
|
+
/**
|
|
113
|
+
* Returns an alive connection if present,
|
|
114
|
+
* otherwise returns a dead connection.
|
|
115
|
+
* By default it filters the `master` only nodes.
|
|
116
|
+
* It uses the selector to choose which
|
|
117
|
+
* connection return.
|
|
118
|
+
*
|
|
119
|
+
* @param {object} options (filter and selector)
|
|
120
|
+
* @returns {object|null} connection
|
|
121
|
+
*/
|
|
122
|
+
getConnection(opts?: getConnectionOptions): Connection | null;
|
|
123
|
+
/**
|
|
124
|
+
* Adds a new connection to the pool.
|
|
125
|
+
*
|
|
126
|
+
* @param {object|string} host
|
|
127
|
+
* @returns {ConnectionPool}
|
|
128
|
+
*/
|
|
129
|
+
addConnection(opts: any): Connection;
|
|
130
|
+
/**
|
|
131
|
+
* Removes a new connection to the pool.
|
|
132
|
+
*
|
|
133
|
+
* @param {object} connection
|
|
134
|
+
* @returns {ConnectionPool}
|
|
135
|
+
*/
|
|
136
|
+
removeConnection(connection: Connection): this;
|
|
137
|
+
/**
|
|
138
|
+
* Empties the connection pool.
|
|
139
|
+
*
|
|
140
|
+
* @returns {ConnectionPool}
|
|
141
|
+
*/
|
|
142
|
+
empty(): this;
|
|
143
|
+
/**
|
|
144
|
+
* Update the ConnectionPool with new connections.
|
|
145
|
+
*
|
|
146
|
+
* @param {array} array of connections
|
|
147
|
+
* @returns {ConnectionPool}
|
|
148
|
+
*/
|
|
149
|
+
update(connections: any[]): this;
|
|
150
|
+
/**
|
|
151
|
+
* Transforms the nodes objects to a host object.
|
|
152
|
+
*
|
|
153
|
+
* @param {object} nodes
|
|
154
|
+
* @returns {array} hosts
|
|
155
|
+
*/
|
|
156
|
+
nodesToHost(nodes: any, protocol: string): any[];
|
|
157
|
+
/**
|
|
158
|
+
* Transforms an url string to a host object
|
|
159
|
+
*
|
|
160
|
+
* @param {string} url
|
|
161
|
+
* @returns {object} host
|
|
162
|
+
*/
|
|
163
|
+
urlToHost(url: string): { url: URL };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
declare class ConnectionPool extends BaseConnectionPool {
|
|
167
|
+
static resurrectStrategies: {
|
|
168
|
+
none: number;
|
|
169
|
+
ping: number;
|
|
170
|
+
optimistic: number;
|
|
171
|
+
};
|
|
172
|
+
dead: string[];
|
|
173
|
+
_sniffEnabled: boolean;
|
|
174
|
+
resurrectTimeout: number;
|
|
175
|
+
resurrectTimeoutCutoff: number;
|
|
176
|
+
pingTimeout: number;
|
|
177
|
+
resurrectStrategy: number;
|
|
178
|
+
constructor(opts?: ConnectionPoolOptions);
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* If enabled, tries to resurrect a connection with the given
|
|
182
|
+
* resurrect strategy ('ping', 'optimistic', 'none').
|
|
183
|
+
*
|
|
184
|
+
* @param {object} { now, requestId, name }
|
|
185
|
+
* @param {function} callback (isAlive, connection)
|
|
186
|
+
*/
|
|
187
|
+
resurrect(opts: resurrectOptions, callback?: (isAlive: boolean | null, connection: Connection | null) => void): void;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
declare class CloudConnectionPool extends BaseConnectionPool {
|
|
191
|
+
cloudConnection: Connection | null
|
|
192
|
+
constructor(opts?: BaseConnectionPoolOptions);
|
|
193
|
+
getConnection(): Connection | null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
declare function defaultNodeFilter(node: Connection): boolean;
|
|
197
|
+
declare function roundRobinSelector(): (connections: Connection[]) => Connection;
|
|
198
|
+
declare function randomSelector(connections: Connection[]): Connection;
|
|
199
|
+
|
|
200
|
+
declare const internals: {
|
|
201
|
+
defaultNodeFilter: typeof defaultNodeFilter;
|
|
202
|
+
roundRobinSelector: typeof roundRobinSelector;
|
|
203
|
+
randomSelector: typeof randomSelector;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export {
|
|
207
|
+
// Interfaces
|
|
208
|
+
ConnectionPoolOptions,
|
|
209
|
+
getConnectionOptions,
|
|
210
|
+
ApiKeyAuth,
|
|
211
|
+
BasicAuth,
|
|
212
|
+
BearerAuth,
|
|
213
|
+
internals,
|
|
214
|
+
resurrectOptions,
|
|
215
|
+
ResurrectEvent,
|
|
216
|
+
// Classes
|
|
217
|
+
BaseConnectionPool,
|
|
218
|
+
ConnectionPool,
|
|
219
|
+
CloudConnectionPool
|
|
220
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
*/
|
|
19
|
+
|
|
20
|
+
'use strict'
|
|
21
|
+
|
|
22
|
+
const BaseConnectionPool = require('./BaseConnectionPool')
|
|
23
|
+
const ConnectionPool = require('./ConnectionPool')
|
|
24
|
+
const CloudConnectionPool = require('./CloudConnectionPool')
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
BaseConnectionPool,
|
|
28
|
+
ConnectionPool,
|
|
29
|
+
CloudConnectionPool
|
|
30
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elastic/elasticsearch",
|
|
3
|
+
"description": "The official Elasticsearch client for Node.js",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"require": "./index.js",
|
|
9
|
+
"import": "./index.mjs"
|
|
10
|
+
},
|
|
11
|
+
"./": "./"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html",
|
|
14
|
+
"version": "7.15.0",
|
|
15
|
+
"versionCanary": "7.15.0-canary.3",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"elasticsearch",
|
|
18
|
+
"elastic",
|
|
19
|
+
"kibana",
|
|
20
|
+
"mapping",
|
|
21
|
+
"REST",
|
|
22
|
+
"search",
|
|
23
|
+
"client",
|
|
24
|
+
"index"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "npm run lint && tap test/{unit,acceptance}/{*,**/*}.test.js && npm run test:types",
|
|
28
|
+
"test:unit": "tap test/unit/{*,**/*}.test.js",
|
|
29
|
+
"test:acceptance": "tap test/acceptance/*.test.js",
|
|
30
|
+
"test:integration": "node test/integration/index.js",
|
|
31
|
+
"test:integration:helpers": "tap test/integration/helpers/*.test.js",
|
|
32
|
+
"test:types": "tsd",
|
|
33
|
+
"test:coverage-100": "tap test/{unit,acceptance}/{*,**/*}.test.js --coverage --100 --nyc-arg=\"--exclude=api\"",
|
|
34
|
+
"test:coverage-report": "tap test/{unit,acceptance}/{*,**/*}.test.js --coverage --nyc-arg=\"--exclude=api\" && nyc report --reporter=text-lcov > coverage.lcov",
|
|
35
|
+
"test:coverage-ui": "tap test/{unit,acceptance}/{*,**/*}.test.js --coverage --coverage-report=html --nyc-arg=\"--exclude=api\"",
|
|
36
|
+
"lint": "standard",
|
|
37
|
+
"lint:fix": "standard --fix",
|
|
38
|
+
"license-checker": "license-checker --production --onlyAllow='MIT;Apache-2.0;Apache1.1;ISC;BSD-3-Clause;BSD-2-Clause'",
|
|
39
|
+
"build-esm": "npx gen-esm-wrapper . index.mjs && standard --fix index.mjs"
|
|
40
|
+
},
|
|
41
|
+
"author": {
|
|
42
|
+
"name": "Tomas Della Vedova",
|
|
43
|
+
"company": "Elastic BV"
|
|
44
|
+
},
|
|
45
|
+
"original-author": {
|
|
46
|
+
"name": "Spencer Alger",
|
|
47
|
+
"company": "Elasticsearch BV"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@sinonjs/fake-timers": "github:sinonjs/fake-timers#0bfffc1",
|
|
51
|
+
"@types/node": "^15.3.1",
|
|
52
|
+
"convert-hrtime": "^5.0.0",
|
|
53
|
+
"cross-zip": "^4.0.0",
|
|
54
|
+
"dedent": "^0.7.0",
|
|
55
|
+
"deepmerge": "^4.2.2",
|
|
56
|
+
"dezalgo": "^1.0.3",
|
|
57
|
+
"fast-deep-equal": "^3.1.3",
|
|
58
|
+
"into-stream": "^6.0.0",
|
|
59
|
+
"js-yaml": "^4.1.0",
|
|
60
|
+
"license-checker": "^25.0.1",
|
|
61
|
+
"minimist": "^1.2.5",
|
|
62
|
+
"node-fetch": "^2.6.1",
|
|
63
|
+
"ora": "^5.4.0",
|
|
64
|
+
"pretty-hrtime": "^1.0.3",
|
|
65
|
+
"proxy": "^1.0.2",
|
|
66
|
+
"rimraf": "^3.0.2",
|
|
67
|
+
"semver": "^7.3.5",
|
|
68
|
+
"simple-git": "^2.39.0",
|
|
69
|
+
"simple-statistics": "^7.7.0",
|
|
70
|
+
"split2": "^3.2.2",
|
|
71
|
+
"standard": "^16.0.3",
|
|
72
|
+
"stoppable": "^1.1.0",
|
|
73
|
+
"tap": "^15.0.9",
|
|
74
|
+
"tsd": "^0.15.1",
|
|
75
|
+
"workq": "^3.0.0",
|
|
76
|
+
"xmlbuilder2": "^2.4.1"
|
|
77
|
+
},
|
|
78
|
+
"dependencies": {
|
|
79
|
+
"debug": "^4.3.1",
|
|
80
|
+
"hpagent": "^0.1.1",
|
|
81
|
+
"ms": "^2.1.3",
|
|
82
|
+
"secure-json-parse": "^2.4.0"
|
|
83
|
+
},
|
|
84
|
+
"license": "Apache-2.0",
|
|
85
|
+
"repository": {
|
|
86
|
+
"type": "git",
|
|
87
|
+
"url": "https://github.com/elastic/elasticsearch-js.git"
|
|
88
|
+
},
|
|
89
|
+
"bugs": {
|
|
90
|
+
"url": "https://github.com/elastic/elasticsearch-js/issues"
|
|
91
|
+
},
|
|
92
|
+
"engines": {
|
|
93
|
+
"node": ">=12"
|
|
94
|
+
},
|
|
95
|
+
"tsd": {
|
|
96
|
+
"directory": "test/types"
|
|
97
|
+
},
|
|
98
|
+
"tap": {
|
|
99
|
+
"ts": false,
|
|
100
|
+
"jsx": false,
|
|
101
|
+
"flow": false,
|
|
102
|
+
"coverage": false,
|
|
103
|
+
"jobs-auto": true,
|
|
104
|
+
"check-coverage": false
|
|
105
|
+
}
|
|
106
|
+
}
|