* Creates all the connections in the pool and switches the keyspace of each connection if needed. * @param {string} keyspace
(keyspace)
| 171 | * @param {string} keyspace |
| 172 | */ |
| 173 | async warmup(keyspace) { |
| 174 | if (this.connections.length < this.coreConnectionsLength) { |
| 175 | while (this.connections.length < this.coreConnectionsLength) { |
| 176 | await this._attemptNewConnection(); |
| 177 | } |
| 178 | |
| 179 | this.log('info', |
| 180 | `Connection pool to host ${this._address} created with ${this.connections.length} connection(s)`); |
| 181 | } else { |
| 182 | this.log('info', `Connection pool to host ${this._address} contains ${this.connections.length} connection(s)`); |
| 183 | } |
| 184 | |
| 185 | if (keyspace) { |
| 186 | try { |
| 187 | for (const connection of this.connections) { |
| 188 | await connection.changeKeyspace(keyspace); |
| 189 | } |
| 190 | } catch (err) { |
| 191 | // Log it and move on, it could be a momentary schema mismatch failure |
| 192 | this.log('warning', `Connection(s) to host ${this._address} could not be switched to keyspace ${keyspace}`); |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | /** @returns {Connection} */ |
| 198 | _createConnection() { |
no test coverage detected