MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / restart

Method restart

lib/request-execution.js:113–141  ·  view source on GitHub ↗

* Borrows the next connection available using the query plan and sends the request. * @returns {Promise }

()

Source from the content-addressed store, hash-verified

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.

Callers 1

_retryMethod · 0.95

Calls 6

_handleErrorMethod · 0.95
_sendOnConnectionMethod · 0.95
getNextConnectionMethod · 0.80
handleNoHostAvailableMethod · 0.80
changeKeyspaceMethod · 0.80
_getErrorCodeMethod · 0.80

Tested by

no test coverage detected