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

Method sendStream

lib/connection.js:524–554  ·  view source on GitHub ↗

* Queues the operation to be written to the wire and invokes the callback once the response was obtained or with an * error (socket error or OperationTimedOutError or serialization-related error). * @param {Request} request * @param {ExecutionOptions|null} execOptions * @param {function}

(request, execOptions, callback)

Source from the content-addressed store, hash-verified

522 * @return {OperationState}
523 */
524 sendStream(request, execOptions, callback) {
525 execOptions = execOptions || ExecutionOptions.empty();
526
527 // Create a new operation that will contain the request, callback and timeouts
528 const operation = new OperationState(request, execOptions.getRowCallback(), (err, response, length) => {
529 if (!err || !err.isSocketError) {
530 // Emit that a response was obtained when there is a valid response
531 // or when the error is not a socket error
532 this.emit('responseDequeued');
533 }
534 callback(err, response, length);
535 });
536
537 const streamId = this._getStreamId();
538
539 // Start the request timeout without waiting for the request to be written
540 operation.setRequestTimeout(execOptions, this.options.socketOptions.readTimeout, this.endpoint,
541 () => this.timedOutOperations++,
542 () => this.timedOutOperations--);
543
544 if (streamId === null) {
545 this.log('info',
546 'Enqueuing ' +
547 this._pendingWrites.length +
548 ', if this message is recurrent consider configuring more connections per host or lowering the pressure');
549 this._pendingWrites.push(operation);
550 return operation;
551 }
552 this._write(operation, streamId);
553 return operation;
554 }
555
556 /**
557 * Pushes the item into the queue.

Callers 7

startupMethod · 0.95
authenticateMethod · 0.95
prepareOnceMethod · 0.95
_idleTimeoutHandlerMethod · 0.95
_sendOnConnectionMethod · 0.80

Calls 6

_getStreamIdMethod · 0.95
setRequestTimeoutMethod · 0.95
_writeMethod · 0.95
emptyMethod · 0.80
getRowCallbackMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected