// 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