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

Method _sendOnConnection

lib/request-execution.js:147–193  ·  view source on GitHub ↗

* Sends the request using the active connection. * @private

()

Source from the content-addressed store, hash-verified

145 * @private
146 */
147 _sendOnConnection() {
148 this._startTime = process.hrtime();
149
150 this._operation =
151 this._connection.sendStream(this._request, this._parent.executionOptions, (err, response, length) => {
152 const errorCode = RequestExecution._getErrorCode(err);
153
154 this._trackResponse(process.hrtime(this._startTime), errorCode, err, length);
155
156 if (this._cancelled) {
157 // Avoid handling the response / err
158 return;
159 }
160
161 if (errorCode !== errorCodes.none) {
162 return this._handleError(errorCode, err);
163 }
164
165 if (response.schemaChange) {
166 return promiseUtils.toBackground(
167 this._parent.client
168 .handleSchemaAgreementAndRefresh(this._connection, response.schemaChange)
169 .then(agreement => {
170 if (this._cancelled) {
171 // After the schema agreement method was started, this execution was cancelled
172 return;
173 }
174
175 this._parent.setCompleted(null, this._getResultSet(response, agreement));
176 })
177 );
178 }
179
180 if (response.keyspaceSet) {
181 this._parent.client.keyspace = response.keyspaceSet;
182 }
183
184 if (response.meta && response.meta.newResultId && this._request.queryId) {
185 // Update the resultId on the existing prepared statement.
186 // Eventually would want to update the result metadata as well (NODEJS-433)
187 const info = this._parent.client.metadata.getPreparedById(this._request.queryId);
188 info.meta.resultId = response.meta.newResultId;
189 }
190
191 this._parent.setCompleted(null, this._getResultSet(response));
192 });
193 }
194
195 _trackResponse(latency, errorCode, err, length) {
196 // Record metrics

Callers 3

startMethod · 0.95
restartMethod · 0.95
_retryMethod · 0.95

Calls 7

_trackResponseMethod · 0.95
_handleErrorMethod · 0.95
_getResultSetMethod · 0.95
sendStreamMethod · 0.80
_getErrorCodeMethod · 0.80
setCompletedMethod · 0.80
getPreparedByIdMethod · 0.80

Tested by

no test coverage detected