src/rate-limited-client.js
// Forward outstanding requests for counters to the child client.
Forward outstanding requests for counters to the child client.
Forward outstanding requests for counters to the child client .
function requestCounters(client, project_key,counter_key) {
  const counter = lookupCounter(client, project_key,counter_key);
  if( !(counter.need > 0) )
    return Promise.resolve();
  if( counter.promise )
    return counter.promise;
  counter.promise = delay(client._rate_limit)
    .then(() => {
      const need = counter.need;
      counter.need = 0;
      return client._child.getCounters(project_key,counter_key,need);
    }).then(result => {
      counter.promise = null;
      counter.have = result;
    }).catch(ex => {
      counter.promise = null;
      throw ex;
    });
  return counter.promise;
}
function requestCounters ( client , project_key , counter_key ) { const counter = lookupCounter ( client , project_key , counter_key ) ; if ( ! ( counter . need > 0 ) ) return Promise . resolve ( ) ; if ( counter . promise ) return counter . promise ; counter . promise = delay ( client . _rate_limit ) . then ( ( ) => { const need = counter . need ; counter . need = 0 ; return client . _child . getCounters ( project_key , counter_key , need ) ; } ) . then ( result => { counter . promise = null ; counter . have = result ; } ) . catch ( ex => { counter . promise = null ; throw ex ; } ) ; return counter . promise ; }
Forward outstanding requests for counters to the child client.
Forward outstanding requests for counters to the child client .