function RequestBackoff(maxErrors, retryIncrement,
                        maxRequests, requestPeriod,
                        timeoutIncrement, maxTimeout) {
  this.MAX_ERRORS_ = maxErrors;
  this.RETRY_INCREMENT_ = retryIncrement;
  this.MAX_REQUESTS_ = maxRequests;
  this.REQUEST_PERIOD_ = requestPeriod;
  this.TIMEOUT_INCREMENT_ = timeoutIncrement;
  this.MAX_TIMEOUT_ = maxTimeout;

  // Queue of ints keeping the time of all requests
  this.requestTimes_ = [];

  this.numErrors_ = 0;
  this.errorTimeout_ = 0;
  this.nextRequestTime_ = 0;
}
/**
 * @param maxErrors Number of times to request before backing off.
 * @param retryIncrement Time (ms) for each retry before backing off.
 * @param maxRequests Number the number of requests needed to trigger backoff
 * @param requestPeriod Number time (ms) in which maxRequests have to occur to
 *     trigger the backoff behavior
 * @param timeoutIncrement Number time (ms) the starting timeout period
 *     we double this time for consecutive errors
 * @param maxTimeout Number time (ms) maximum timeout period
 */
@param maxErrors Number of times to request before backing off.
@param retryIncrement Time (ms) for each retry before backing off.
@param maxRequests Number the number of requests needed to trigger backoff
@param requestPeriod Number time (ms) in which maxRequests have to occur to
trigger the backoff behavior
@param timeoutIncrement Number time (ms) the starting timeout period
we double this time for consecutive errors
@param maxTimeout Number time (ms) maximum timeout period
@param maxErrors Number of times to request before backing off . @param retryIncrement Time ( ms ) for each retry before backing off . @param maxRequests Number the number of requests needed to trigger backoff @param requestPeriod Number time ( ms ) in which maxRequests have to occur to trigger the backoff behavior @param timeoutIncrement Number time ( ms ) the starting timeout period we double this time for consecutive errors @param maxTimeout Number time ( ms ) maximum timeout period
function RequestBackoff(maxErrors, retryIncrement,
                        maxRequests, requestPeriod,
                        timeoutIncrement, maxTimeout) {
  this.MAX_ERRORS_ = maxErrors;
  this.RETRY_INCREMENT_ = retryIncrement;
  this.MAX_REQUESTS_ = maxRequests;
  this.REQUEST_PERIOD_ = requestPeriod;
  this.TIMEOUT_INCREMENT_ = timeoutIncrement;
  this.MAX_TIMEOUT_ = maxTimeout;
  this.requestTimes_ = [];
  this.numErrors_ = 0;
  this.errorTimeout_ = 0;
  this.nextRequestTime_ = 0;
}
function RequestBackoff ( maxErrors , retryIncrement , maxRequests , requestPeriod , timeoutIncrement , maxTimeout ) { this . MAX_ERRORS_ = maxErrors ; this . RETRY_INCREMENT_ = retryIncrement ; this . MAX_REQUESTS_ = maxRequests ; this . REQUEST_PERIOD_ = requestPeriod ; this . TIMEOUT_INCREMENT_ = timeoutIncrement ; this . MAX_TIMEOUT_ = maxTimeout ; this . requestTimes_ = [ ] ; this . numErrors_ = 0 ; this . errorTimeout_ = 0 ; this . nextRequestTime_ = 0 ; }
@param maxErrors Number of times to request before backing off.
@param maxErrors Number of times to request before backing off .
// Queue of ints keeping the time of all requests