Skip to content

Commit 8e86450

Browse files
committed
Refactored connection pool (#913)
* Refactored ConnectionPool - Created BaseConnectionPool class - Created CloudConnectionPool - connection pool updates are immutable - resurrect now happens inside getConnection() * Rewritten connection pool(s) type definitions * Updated test * Fixed test * Fix if check * Removed old files * Improve code coverage * Updated license header * Fix if check * Improve code coverage * Updated coverage script
1 parent 90be646 commit 8e86450

19 files changed

+1301
-616
lines changed

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Transport, {
1818
} from './lib/Transport';
1919
import { URL } from 'url';
2020
import Connection, { AgentOptions, agentFn } from './lib/Connection';
21-
import ConnectionPool, { ResurrectEvent, BasicAuth, ApiKeyAuth } from './lib/ConnectionPool';
21+
import { ConnectionPool, ResurrectEvent, BasicAuth, ApiKeyAuth } from './lib/pool';
2222
import Serializer from './lib/Serializer';
2323
import * as RequestParams from './api/requestParams';
2424
import * as errors from './lib/errors';

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { URL } = require('url')
99
const debug = require('debug')('elasticsearch')
1010
const Transport = require('./lib/Transport')
1111
const Connection = require('./lib/Connection')
12-
const ConnectionPool = require('./lib/ConnectionPool')
12+
const { ConnectionPool, CloudConnectionPool } = require('./lib/pool')
1313
const Serializer = require('./lib/Serializer')
1414
const errors = require('./lib/errors')
1515
const { ConfigurationError } = errors
@@ -59,9 +59,9 @@ class Client extends EventEmitter {
5959

6060
const options = Object.assign({}, {
6161
Connection,
62-
ConnectionPool,
6362
Transport,
6463
Serializer,
64+
ConnectionPool: opts.cloud ? CloudConnectionPool : ConnectionPool,
6565
maxRetries: 3,
6666
requestTimeout: 30000,
6767
pingTimeout: 3000,

lib/Connection.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { URL } from 'url';
88
import { inspect, InspectOptions } from 'util';
9-
import { ApiKeyAuth, BasicAuth } from './ConnectionPool'
9+
import { ApiKeyAuth, BasicAuth } from './pool'
1010
import * as http from 'http';
1111
import { ConnectionOptions as TlsConnectionOptions } from 'tls';
1212

0 commit comments

Comments
 (0)