* Borrows the next connection available using the query plan and sends the request. * @returns {Promise }
()
| 111 | * @returns {Promise<void>} |
| 112 | */ |
| 113 | async restart() { |
| 114 | try { |
| 115 | const { host, connection } = this._parent.getNextConnection(); |
| 116 | |
| 117 | this._connection = connection; |
| 118 | this._host = host; |
| 119 | } catch (err) { |
| 120 | return this._parent.handleNoHostAvailable(err, this); |
| 121 | } |
| 122 | |
| 123 | // It could be a new connection from the pool, we should make sure it's in the correct keyspace. |
| 124 | const keyspace = this._parent.client.keyspace; |
| 125 | if (keyspace && keyspace !== this._connection.keyspace) { |
| 126 | try { |
| 127 | await this._connection.changeKeyspace(keyspace); |
| 128 | } catch (err) { |
| 129 | // When its a socket error, attempt to retry. |
| 130 | // Otherwise, rethrow the error to the user. |
| 131 | return this._handleError(RequestExecution._getErrorCode(err), err); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | if (this._cancelled) { |
| 136 | // No need to send the request or invoke any callback |
| 137 | return; |
| 138 | } |
| 139 | |
| 140 | this._sendOnConnection(); |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Sends the request using the active connection. |
no test coverage detected