Disable client Helpers in Node.js < 10. (#1194)
This commit is contained in:
committed by
delvedor
parent
c343302772
commit
11951fe8fc
2
.github/workflows/nodejs.yml
vendored
2
.github/workflows/nodejs.yml
vendored
@ -63,7 +63,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
npm run test:unit -- --node-arg=--harmony-async-iteration
|
npm run test:node8
|
||||||
|
|
||||||
helpers-integration-test:
|
helpers-integration-test:
|
||||||
name: Helpers integration test
|
name: Helpers integration test
|
||||||
|
|||||||
@ -4,8 +4,7 @@
|
|||||||
The client comes with an handy collection of helpers to give you a more comfortable experience with some APIs.
|
The client comes with an handy collection of helpers to give you a more comfortable experience with some APIs.
|
||||||
|
|
||||||
CAUTION: The client helpers are experimental, and the API may change in the next minor releases.
|
CAUTION: The client helpers are experimental, and the API may change in the next minor releases.
|
||||||
If you are using the client with Node.js v8 you should run your code with the `--harmony-async-iteration` argument. +
|
The helpers will not work in any Node.js version lower than 10.
|
||||||
eg: `node --harmony-async-iteration index.js`
|
|
||||||
|
|
||||||
=== Bulk Helper
|
=== Bulk Helper
|
||||||
Running Bulk requests can be complex due to the shape of the API, this helper aims to provide a nicer developer experience around the Bulk API.
|
Running Bulk requests can be complex due to the shape of the API, this helper aims to provide a nicer developer experience around the Bulk API.
|
||||||
|
|||||||
7
index.js
7
index.js
@ -4,13 +4,16 @@
|
|||||||
|
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
const nodeMajor = Number(process.versions.node.split('.')[0])
|
||||||
|
|
||||||
const { EventEmitter } = require('events')
|
const { EventEmitter } = require('events')
|
||||||
const { URL } = require('url')
|
const { URL } = require('url')
|
||||||
const debug = require('debug')('elasticsearch')
|
const debug = require('debug')('elasticsearch')
|
||||||
const Transport = require('./lib/Transport')
|
const Transport = require('./lib/Transport')
|
||||||
const Connection = require('./lib/Connection')
|
const Connection = require('./lib/Connection')
|
||||||
const { ConnectionPool, CloudConnectionPool } = require('./lib/pool')
|
const { ConnectionPool, CloudConnectionPool } = require('./lib/pool')
|
||||||
const Helpers = require('./lib/Helpers')
|
// Helpers works only in Node.js >= 10
|
||||||
|
const Helpers = nodeMajor < 10 ? null : require('./lib/Helpers')
|
||||||
const Serializer = require('./lib/Serializer')
|
const Serializer = require('./lib/Serializer')
|
||||||
const errors = require('./lib/errors')
|
const errors = require('./lib/errors')
|
||||||
const { ConfigurationError } = errors
|
const { ConfigurationError } = errors
|
||||||
@ -127,7 +130,9 @@ class Client extends EventEmitter {
|
|||||||
opaqueIdPrefix: options.opaqueIdPrefix
|
opaqueIdPrefix: options.opaqueIdPrefix
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (Helpers !== null) {
|
||||||
this.helpers = new Helpers({ client: this, maxRetries: options.maxRetries })
|
this.helpers = new Helpers({ client: this, maxRetries: options.maxRetries })
|
||||||
|
}
|
||||||
|
|
||||||
const apis = buildApi({
|
const apis = buildApi({
|
||||||
makeRequest: this.transport.request.bind(this.transport),
|
makeRequest: this.transport.request.bind(this.transport),
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run lint && npm run test:unit && npm run test:behavior && npm run test:types",
|
"test": "npm run lint && npm run test:unit && npm run test:behavior && npm run test:types",
|
||||||
|
"test:node8": "npm run lint && tap test/unit/*.test.js -t 300 --no-coverage && npm run test:behavior && npm run test:types",
|
||||||
"test:unit": "tap test/unit/*.test.js test/unit/**/*.test.js -t 300 --no-coverage",
|
"test:unit": "tap test/unit/*.test.js test/unit/**/*.test.js -t 300 --no-coverage",
|
||||||
"test:behavior": "tap test/behavior/*.test.js -t 300 --no-coverage",
|
"test:behavior": "tap test/behavior/*.test.js -t 300 --no-coverage",
|
||||||
"test:integration": "node test/integration/index.js",
|
"test:integration": "node test/integration/index.js",
|
||||||
|
|||||||
Reference in New Issue
Block a user