@@ -24,7 +24,6 @@ import os from 'os'
24
24
import {
25
25
Transport ,
26
26
UndiciConnection ,
27
- WeightedConnectionPool ,
28
27
CloudConnectionPool ,
29
28
Serializer ,
30
29
Diagnostic ,
@@ -35,16 +34,13 @@ import {
35
34
HttpAgentOptions ,
36
35
UndiciAgentOptions ,
37
36
agentFn ,
38
- nodeFilterFn ,
39
- nodeSelectorFn ,
40
37
generateRequestIdFn ,
41
38
BasicAuth ,
42
39
ApiKeyAuth ,
43
40
BearerAuth ,
44
41
Context
45
42
} from '@elastic/transport/lib/types'
46
43
import BaseConnection , { prepareHeaders } from '@elastic/transport/lib/connection/BaseConnection'
47
- import SniffingTransport from './sniffingTransport'
48
44
import Helpers from './helpers'
49
45
import API from './api'
50
46
@@ -89,16 +85,10 @@ export interface ClientOptions {
89
85
maxRetries ?: number
90
86
requestTimeout ?: number
91
87
pingTimeout ?: number
92
- sniffInterval ?: number | boolean
93
- sniffOnStart ?: boolean
94
- sniffEndpoint ?: string
95
- sniffOnConnectionFault ?: boolean
96
88
resurrectStrategy ?: 'ping' | 'optimistic' | 'none'
97
89
compression ?: boolean
98
90
tls ?: TlsConnectionOptions
99
91
agent ?: HttpAgentOptions | UndiciAgentOptions | agentFn | false
100
- nodeFilter ?: nodeFilterFn
101
- nodeSelector ?: nodeSelectorFn
102
92
headers ?: Record < string , any >
103
93
opaqueIdPrefix ?: string
104
94
generateRequestId ?: generateRequestIdFn
@@ -120,7 +110,7 @@ export default class Client extends API {
120
110
diagnostic : Diagnostic
121
111
name : string | symbol
122
112
connectionPool : BaseConnectionPool
123
- transport : SniffingTransport
113
+ transport : Transport
124
114
serializer : Serializer
125
115
helpers : Helpers
126
116
constructor ( opts : ClientOptions ) {
@@ -160,25 +150,20 @@ export default class Client extends API {
160
150
161
151
const options : Required < ClientOptions > = Object . assign ( { } , {
162
152
Connection : UndiciConnection ,
163
- Transport : SniffingTransport ,
153
+ Transport,
164
154
Serializer,
165
- ConnectionPool : ( opts . cloud != null ) ? CloudConnectionPool : WeightedConnectionPool ,
155
+ ConnectionPool : CloudConnectionPool ,
166
156
maxRetries : 3 ,
167
157
requestTimeout : 30000 ,
168
158
pingTimeout : 3000 ,
169
- sniffInterval : false ,
170
- sniffOnStart : false ,
171
- sniffEndpoint : '_nodes/_all/http' ,
172
- sniffOnConnectionFault : false ,
173
159
resurrectStrategy : 'ping' ,
174
- compression : false ,
160
+ compression : true ,
175
161
tls : null ,
176
162
caFingerprint : null ,
177
163
agent : null ,
178
164
headers : {
179
165
'user-agent' : `elasticsearch-js/${ clientVersion } Node.js ${ nodeVersion } ; Transport ${ transportVersion } ; (${ os . platform ( ) } ${ os . release ( ) } ${ os . arch ( ) } )`
180
166
} ,
181
- nodeFilter : null ,
182
167
generateRequestId : null ,
183
168
name : 'elasticsearch-js' ,
184
169
auth : null ,
@@ -232,7 +217,13 @@ export default class Client extends API {
232
217
diagnostic : this . diagnostic ,
233
218
caFingerprint : options . caFingerprint
234
219
} )
235
- this . connectionPool . addConnection ( options . node ?? options . nodes )
220
+
221
+ // serverless only supports one node. keeping array support, to simplify
222
+ // for people migrating from the stack client, but only using the first
223
+ // node in the list.
224
+ let node = options . node ?? options . nodes
225
+ if ( Array . isArray ( node ) ) node = node [ 0 ]
226
+ this . connectionPool . addConnection ( node )
236
227
}
237
228
238
229
this . transport = new options . Transport ( {
@@ -241,14 +232,8 @@ export default class Client extends API {
241
232
serializer : this . serializer ,
242
233
maxRetries : options . maxRetries ,
243
234
requestTimeout : options . requestTimeout ,
244
- sniffInterval : options . sniffInterval ,
245
- sniffOnStart : options . sniffOnStart ,
246
- sniffOnConnectionFault : options . sniffOnConnectionFault ,
247
- sniffEndpoint : options . sniffEndpoint ,
248
235
compression : options . compression ,
249
236
headers : options . headers ,
250
- nodeFilter : options . nodeFilter ,
251
- nodeSelector : options . nodeSelector ,
252
237
generateRequestId : options . generateRequestId ,
253
238
name : options . name ,
254
239
opaqueIdPrefix : options . opaqueIdPrefix ,
@@ -276,7 +261,7 @@ export default class Client extends API {
276
261
// Merge the new options with the initial ones
277
262
// @ts -expect-error kChild symbol is for internal use only
278
263
const options : ClientOptions = Object . assign ( { } , this [ kInitialOptions ] , opts )
279
- // Pass to the child client the parent instances that cannot be overriden
264
+ // Pass to the child client the parent instances that cannot be overridden
280
265
// @ts -expect-error kInitialOptions symbol is for internal use only
281
266
options [ kChild ] = {
282
267
connectionPool : this . connectionPool ,
0 commit comments