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

Method setRequestTimeout

lib/operation-state.js:95–111  ·  view source on GitHub ↗

* Creates the timeout for the request. * @param {ExecutionOptions} execOptions * @param {Number} defaultReadTimeout * @param {String} address * @param {Function} onTimeout The callback to be invoked when it times out. * @param {Function} onResponse The callback to be invoked if a resp

(execOptions, defaultReadTimeout, address, onTimeout, onResponse)

Source from the content-addressed store, hash-verified

93 * @param {Function} onResponse The callback to be invoked if a response is obtained after it timed out.
94 */
95 setRequestTimeout(execOptions, defaultReadTimeout, address, onTimeout, onResponse) {
96 if (this._state !== state.init) {
97 // No need to set the timeout
98 return;
99 }
100 const millis = execOptions.getReadTimeout() !== undefined ? execOptions.getReadTimeout() : defaultReadTimeout;
101 if (!(millis > 0)) {
102 // Read timeout disabled
103 return;
104 }
105 const self = this;
106 this._timeout = setTimeout(function requestTimedOut() {
107 onTimeout();
108 const message = util.format('The host %s did not reply before timeout %d ms', address, millis);
109 self._markAsTimedOut(new errors.OperationTimedOutError(message, address), onResponse);
110 }, millis);
111 }
112
113 setResultRow(row, meta, rowLength, flags, header) {
114 this._markAsCompleted();

Callers 1

sendStreamMethod · 0.95

Calls 2

_markAsTimedOutMethod · 0.80
getReadTimeoutMethod · 0.65

Tested by

no test coverage detected