Updated Connections handling (#1127)
* Updated Connections handling - The ConnectionPool.getConnection method now always returns a connection - The ConnectionPool.update mehtod now cleans the dead list - Deprecated the NoLivingConnectionsError * Updated test * Updated docs * The NoLivingConnectionsError can still happen if the filter/selector returns no nodes * Updated test * Updated docs * Catch undefined connections as well * Updated test * Updated ApiError type def
This commit is contained in:
committed by
GitHub
parent
85616b07ef
commit
f913f7d2d2
@ -335,9 +335,10 @@ test('Not JSON payload from server', t => {
|
||||
})
|
||||
})
|
||||
|
||||
test('NoLivingConnectionsError', t => {
|
||||
t.plan(1)
|
||||
test('NoLivingConnectionsError (null connection)', t => {
|
||||
t.plan(3)
|
||||
const pool = new ConnectionPool({ Connection })
|
||||
pool.addConnection('http://localhost:9200')
|
||||
|
||||
const transport = new Transport({
|
||||
emit: () => {},
|
||||
@ -346,7 +347,40 @@ test('NoLivingConnectionsError', t => {
|
||||
maxRetries: 3,
|
||||
requestTimeout: 30000,
|
||||
sniffInterval: false,
|
||||
sniffOnStart: false
|
||||
sniffOnStart: false,
|
||||
nodeSelector (connections) {
|
||||
t.is(connections.length, 1)
|
||||
t.true(connections[0] instanceof Connection)
|
||||
return null
|
||||
}
|
||||
})
|
||||
|
||||
transport.request({
|
||||
method: 'GET',
|
||||
path: '/hello'
|
||||
}, (err, { body }) => {
|
||||
t.ok(err instanceof NoLivingConnectionsError)
|
||||
})
|
||||
})
|
||||
|
||||
test('NoLivingConnectionsError (undefined connection)', t => {
|
||||
t.plan(3)
|
||||
const pool = new ConnectionPool({ Connection })
|
||||
pool.addConnection('http://localhost:9200')
|
||||
|
||||
const transport = new Transport({
|
||||
emit: () => {},
|
||||
connectionPool: pool,
|
||||
serializer: new Serializer(),
|
||||
maxRetries: 3,
|
||||
requestTimeout: 30000,
|
||||
sniffInterval: false,
|
||||
sniffOnStart: false,
|
||||
nodeSelector (connections) {
|
||||
t.is(connections.length, 1)
|
||||
t.true(connections[0] instanceof Connection)
|
||||
return undefined
|
||||
}
|
||||
})
|
||||
|
||||
transport.request({
|
||||
|
||||
Reference in New Issue
Block a user