* Executes a query using the active connection * @param {String|Request} cqlQuery * @param {Boolean} [waitReconnect] Determines if it should wait for reconnection in case the control connection is not * connected at the moment. Default: true.
(cqlQuery, waitReconnect = true)
| 963 | * connected at the moment. Default: true. |
| 964 | */ |
| 965 | async query(cqlQuery, waitReconnect = true) { |
| 966 | const queryOnConnection = async () => { |
| 967 | if (!this.connection || this._isShuttingDown) { |
| 968 | throw new errors.NoHostAvailableError({}, 'ControlConnection is not connected at the time'); |
| 969 | } |
| 970 | |
| 971 | const request = typeof cqlQuery === 'string' ? new requests.QueryRequest(cqlQuery, null, null) : cqlQuery; |
| 972 | return await this.connection.send(request, null); |
| 973 | }; |
| 974 | |
| 975 | if (!this.connection && waitReconnect) { |
| 976 | // Wait until its reconnected (or timer elapses) |
| 977 | await this._waitForReconnection(); |
| 978 | } |
| 979 | |
| 980 | return await queryOnConnection(); |
| 981 | } |
| 982 | |
| 983 | /** @returns {Encoder} The encoder used by the current connection */ |
| 984 | getEncoder() { |
no test coverage detected