lib/connection/statement.js
function sendSfRequest(statementContext, options, appendQueryParamOnRetry)
{
  var sf = statementContext.services.sf;
  var connectionConfig = statementContext.connectionConfig;

  // clone the options
  options = Util.apply({}, options);

  // get the original url and callback
  var urlOrig = options.url;
  var callbackOrig = options.callback;

  var numRetries = 0;
  var maxNumRetries = connectionConfig.getRetrySfMaxNumRetries();
  var sleep = connectionConfig.getRetrySfStartingSleepTime();

  // create a function to send the request
  var sendRequest = function sendRequest()
  {
    // if this is a retry and a query parameter should be appended to the url on
    // retry, update the url
    if ((numRetries > 0) && appendQueryParamOnRetry)
    {
      options.url = Util.url.appendParam(urlOrig, 'retry', true);
    }

    sf.request(options);
  };

  // replace the specified callback with a new one that retries
  options.callback = function(err)
  {
    // if we haven't exceeded the maximum number of retries yet and the server
    // came back with a retryable error code
    if (numRetries < maxNumRetries &&
        err && Util.isRetryableHttpError(
          err.response, false // no retry for HTTP 403
      ))
    {
      // increment the retry count
      numRetries++;

      // use exponential backoff with decorrelated jitter to compute the
      // next sleep time.
      var cap = connectionConfig.getRetrySfMaxSleepTime();
      sleep = Util.nextSleepTime(1, cap, sleep);

      Logger.getInstance().debug(
          'Retrying statement with request id %s, retry count = %s',
          statementContext.requestId, numRetries);

      // wait the appropriate amount of time before retrying the request
      setTimeout(sendRequest, sleep * 1000);
    }
    else
    {
      // invoke the original callback
      callbackOrig.apply(this, arguments);
    }
  };

  // issue the request
  sendRequest();
}
function sendSfRequest(statementContext, options, appendQueryParamOnRetry)
{
  var sf = statementContext.services.sf;
  var connectionConfig = statementContext.connectionConfig;

  // clone the options
  options = Util.apply({}, options);

  // get the original url and callback
  var urlOrig = options.url;
  var callbackOrig = options.callback;

  var numRetries = 0;
  var maxNumRetries = connectionConfig.getRetrySfMaxNumRetries();
  var sleep = connectionConfig.getRetrySfStartingSleepTime();

  // create a function to send the request
  var sendRequest = function sendRequest()
  {
    // if this is a retry and a query parameter should be appended to the url on
    // retry, update the url
    if ((numRetries > 0) && appendQueryParamOnRetry)
    {
      options.url = Util.url.appendParam(urlOrig, 'retry', true);
    }

    sf.request(options);
  };

  // replace the specified callback with a new one that retries
  options.callback = function(err)
  {
    // if we haven't exceeded the maximum number of retries yet and the server
    // came back with a retryable error code
    if (numRetries < maxNumRetries &&
        err && Util.isRetryableHttpError(
          err.response, false // no retry for HTTP 403
      ))
    {
      // increment the retry count
      numRetries++;

      // use exponential backoff with decorrelated jitter to compute the
      // next sleep time.
      var cap = connectionConfig.getRetrySfMaxSleepTime();
      sleep = Util.nextSleepTime(1, cap, sleep);

      Logger.getInstance().debug(
          'Retrying statement with request id %s, retry count = %s',
          statementContext.requestId, numRetries);

      // wait the appropriate amount of time before retrying the request
      setTimeout(sendRequest, sleep * 1000);
    }
    else
    {
      // invoke the original callback
      callbackOrig.apply(this, arguments);
    }
  };

  // issue the request
  sendRequest();
}
function sendSfRequest ( statementContext , options , appendQueryParamOnRetry ) { var sf = statementContext . services . sf ; var connectionConfig = statementContext . connectionConfig ; // clone the options options = Util . apply ( { } , options ) ; // get the original url and callback var urlOrig = options . url ; var callbackOrig = options . callback ; var numRetries = 0 ; var maxNumRetries = connectionConfig . getRetrySfMaxNumRetries ( ) ; var sleep = connectionConfig . getRetrySfStartingSleepTime ( ) ; // create a function to send the request var sendRequest = function sendRequest ( ) { // if this is a retry and a query parameter should be appended to the url on // retry, update the url if ( ( numRetries > 0 ) && appendQueryParamOnRetry ) { options . url = Util . url . appendParam ( urlOrig , 'retry' , true ) ; } sf . request ( options ) ; } ; // replace the specified callback with a new one that retries options . callback = function ( err ) { // if we haven't exceeded the maximum number of retries yet and the server // came back with a retryable error code if ( numRetries < maxNumRetries && err && Util . isRetryableHttpError ( err . response , false // no retry for HTTP 403 ) ) { // increment the retry count numRetries ++ ; // use exponential backoff with decorrelated jitter to compute the // next sleep time. var cap = connectionConfig . getRetrySfMaxSleepTime ( ) ; sleep = Util . nextSleepTime ( 1 , cap , sleep ) ; Logger . getInstance ( ) . debug ( 'Retrying statement with request id %s, retry count = %s' , statementContext . requestId , numRetries ) ; // wait the appropriate amount of time before retrying the request setTimeout ( sendRequest , sleep * 1000 ) ; } else { // invoke the original callback callbackOrig . apply ( this , arguments ) ; } } ; // issue the request sendRequest ( ) ; }
Issues a statement-related request using the Snowflake service.

@param {Object} statementContext the statement context.
@param {Object} options the request options.
@param {Boolean} [appendQueryParamOnRetry] whether retry=true should be
appended to the url if the request is retried.
Issues a statement - related request using the Snowflake service .