influx 5.11.0 → 5.12.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.
@@ -161,6 +161,10 @@ export interface IQueryOptions {
161
161
  * Execute a query as a HTTP GET or POST request
162
162
  */
163
163
  method?: "GET" | "POST";
164
+ /**
165
+ * Abort Signal to cancel the query request
166
+ */
167
+ signal?: AbortSignal;
164
168
  }
165
169
  export interface IParseOptions {
166
170
  /**
package/lib/src/index.js CHANGED
@@ -1000,7 +1000,7 @@ class InfluxDB {
1000
1000
  q: query,
1001
1001
  rp: retentionPolicy,
1002
1002
  params: JSON.stringify(placeholders),
1003
- }, options.method, true));
1003
+ }, options.method, true, options.signal));
1004
1004
  }
1005
1005
  /**
1006
1006
  * Pings all available hosts, collecting online status and version info.
@@ -1040,7 +1040,7 @@ class InfluxDB {
1040
1040
  * Creates options to be passed into the pool to query databases.
1041
1041
  * @private
1042
1042
  */
1043
- _getQueryOpts(params, method = "GET", partOfBody = false) {
1043
+ _getQueryOpts(params, method = "GET", partOfBody = false, signal = undefined) {
1044
1044
  let auth = undefined;
1045
1045
  if (typeof this._options.username === "string") {
1046
1046
  auth = `${this._options.username}:${this._options.password || ""}`;
@@ -1048,6 +1048,7 @@ class InfluxDB {
1048
1048
  if (method === "POST" && partOfBody) {
1049
1049
  return {
1050
1050
  method,
1051
+ signal,
1051
1052
  path: "/query",
1052
1053
  auth,
1053
1054
  body: querystring.stringify(params),
@@ -1056,6 +1057,7 @@ class InfluxDB {
1056
1057
  else {
1057
1058
  return {
1058
1059
  method,
1060
+ signal,
1059
1061
  path: "/query",
1060
1062
  auth,
1061
1063
  query: Object.assign({}, params),
package/lib/src/pool.d.ts CHANGED
@@ -52,6 +52,10 @@ export interface IPoolRequestOptions {
52
52
  * Optional extra headers to include in the request.
53
53
  */
54
54
  headers?: http.OutgoingHttpHeaders;
55
+ /**
56
+ * Optional abort signal to cancel the request.
57
+ */
58
+ signal?: AbortSignal;
55
59
  }
56
60
  /**
57
61
  * An ServiceNotAvailableError is returned as an error from requests that
package/lib/src/pool.js CHANGED
@@ -262,8 +262,9 @@ class Pool {
262
262
  const encodedAuth = Buffer.from(options.auth).toString("base64");
263
263
  mergedHeaders["Authorization"] = `Basic ${encodedAuth}`;
264
264
  }
265
- const _a = (host.options || {}), { headers: _ignoredHostHeaders } = _a, hostReqOptions = __rest(_a, ["headers"]);
266
- const req = request(Object.assign({ headers: mergedHeaders, hostname: host.url.hostname, method: options.method, path, port: Number(host.url.port), protocol: host.url.protocol, timeout: this._timeout }, hostReqOptions), once((res) => {
265
+ const _a = (host.options ||
266
+ {}), { headers: _ignoredHostHeaders } = _a, hostReqOptions = __rest(_a, ["headers"]);
267
+ const req = request(Object.assign({ headers: mergedHeaders, hostname: host.url.hostname, method: options.method, signal: options.signal, path, port: Number(host.url.port), protocol: host.url.protocol, timeout: this._timeout }, hostReqOptions), once((res) => {
267
268
  res.setEncoding("utf8");
268
269
  if (res.statusCode >= 500) {
269
270
  res.on("data", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "influx",
3
- "version": "5.11.0",
3
+ "version": "5.12.0",
4
4
  "description": "InfluxDB Client",
5
5
  "main": "./lib/src/index.js",
6
6
  "typings": "./lib/src/index",