startRequest_(request) {
    this.numPendingRequests_++;
    Assertions.assert(
        request.numAttemptsLeft > 0, 'request.numAttemptsLeft > 0');
    request.numAttemptsLeft--;

    const cleanUpAndStartNextRequest = () => {
      this.numPendingRequests_--;
      this.startNextRequestFromQueue_();
    };

    this.sendOneAttempt_(request).then(
        response => {
          request.resolver.resolve(response);
          cleanUpAndStartNextRequest();
        },
        e => {
          if (request.numAttemptsLeft == 0) {
            request.resolver.reject(e);
          } else {
            // Try it again later by re-adding the request to back of queue.

            this.queuedRequests_.push(request);
          }
          cleanUpAndStartNextRequest();
        });
  }
/**
   * Attempts the given request once. If successful, resolves the
   * PromiseResolver with the result. Otherwise, requeues the request for retry,
   * or rejects the PromiseResolver if it ran out of attempts. Also processes a
   * queued request, if any, at the end.
   * @param {!QueueEntry_} request
   * @private
   */
Attempts the given request once. If successful, resolves the
PromiseResolver with the result. Otherwise, requeues the request for retry,
or rejects the PromiseResolver if it ran out of attempts. Also processes a
queued request, if any, at the end.
@param {!QueueEntry_} request
@private
Attempts the given request once . If successful resolves the PromiseResolver with the result . Otherwise requeues the request for retry or rejects the PromiseResolver if it ran out of attempts . Also processes a queued request if any at the end . @param { !QueueEntry_ } request @private
startRequest_(request) {
    this.numPendingRequests_++;
    Assertions.assert(
        request.numAttemptsLeft > 0, 'request.numAttemptsLeft > 0');
    request.numAttemptsLeft--;
    const cleanUpAndStartNextRequest = () => {
      this.numPendingRequests_--;
      this.startNextRequestFromQueue_();
    };
    this.sendOneAttempt_(request).then(
        response => {
          request.resolver.resolve(response);
          cleanUpAndStartNextRequest();
        },
        e => {
          if (request.numAttemptsLeft == 0) {
            request.resolver.reject(e);
          } else {
            this.queuedRequests_.push(request);
          }
          cleanUpAndStartNextRequest();
        });
  }
startRequest_ ( request ) { this . numPendingRequests_ ++ ; Assertions . assert ( request . numAttemptsLeft > 0 , 'request.numAttemptsLeft > 0' ) ; request . numAttemptsLeft -- ; const cleanUpAndStartNextRequest = ( ) => { this . numPendingRequests_ -- ; this . startNextRequestFromQueue_ ( ) ; } ; this . sendOneAttempt_ ( request ) . then ( response => { request . resolver . resolve ( response ) ; cleanUpAndStartNextRequest ( ) ; } , e => { if ( request . numAttemptsLeft == 0 ) { request . resolver . reject ( e ) ; } else { this . queuedRequests_ . push ( request ) ; } cleanUpAndStartNextRequest ( ) ; } ) ; }
Attempts the given request once.
Attempts the given request once .
// Try it again later by re-adding the request to back of queue.