DelayResult getThrottlingDelay ( ) { // These delays are not additive. There's no benefit to adding a batching delay on top of a throttling delay, since // a throttling delay will have increased batching as a side effect. int maxDelay = 0 ; boolean maximum = false ; for ( Throttler t : this . throttlers ) { int delay = t . getDelayMillis ( ) ; if ( delay >= MAX_DELAY_MILLIS ) { // This throttler introduced the maximum delay. No need to search more. maxDelay = MAX_DELAY_MILLIS ; maximum = true ; break ; } maxDelay = Math . max ( maxDelay , delay ) ; } return new DelayResult ( maxDelay , maximum ) ; }
Calculates the amount of time needed to delay based on the configured throttlers . The computed result is not additive as there is no benefit to adding delays from various Throttle Calculators together . For example a cache throttling delay will have increased batching as a side effect so there s no need to include the batching one as well .