Support for Elasticsearch 7.3 (#928)
This commit is contained in:
committed by
GitHub
parent
823c209c32
commit
8c78f47ac3
49
lib/pool/CloudConnectionPool.js
Normal file
49
lib/pool/CloudConnectionPool.js
Normal file
@ -0,0 +1,49 @@
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
const BaseConnectionPool = require('./BaseConnectionPool')
|
||||
|
||||
class CloudConnectionPool extends BaseConnectionPool {
|
||||
constructor (opts = {}) {
|
||||
super(opts)
|
||||
this.cloudConnection = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the only cloud connection.
|
||||
*
|
||||
* @returns {object} connection
|
||||
*/
|
||||
getConnection () {
|
||||
return this.cloudConnection
|
||||
}
|
||||
|
||||
/**
|
||||
* Empties the connection pool.
|
||||
*
|
||||
* @returns {ConnectionPool}
|
||||
*/
|
||||
empty (callback) {
|
||||
super.empty(() => {
|
||||
this.cloudConnection = null
|
||||
callback()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ConnectionPool with new connections.
|
||||
*
|
||||
* @param {array} array of connections
|
||||
* @returns {ConnectionPool}
|
||||
*/
|
||||
update (connections) {
|
||||
super.update(connections)
|
||||
this.cloudConnection = this.connections[0]
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CloudConnectionPool
|
||||
Reference in New Issue
Block a user