File tree Expand file tree Collapse file tree
src/main/java/dev/openfga/sdk/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,28 +40,7 @@ private ExponentialBackoff() {
4040 * @return Duration representing the delay before the next retry
4141 */
4242 public static Duration calculateDelay (int retryCount ) {
43- if (retryCount < 0 ) {
44- return Duration .ZERO ;
45- }
46-
47- // Calculate base delay: 2^retryCount * 100ms
48- long baseDelayMs = (long ) Math .pow (2 , retryCount ) * BASE_DELAY_MS ;
49-
50- // Cap at maximum delay
51- long maxDelayMs = MAX_DELAY_SECONDS * 1000L ;
52- if (baseDelayMs > maxDelayMs ) {
53- baseDelayMs = maxDelayMs ;
54- }
55-
56- // Add jitter: random value between baseDelay and 2 * baseDelay
57- long minDelayMs = baseDelayMs ;
58- long maxDelayMsWithJitter = Math .min (baseDelayMs * 2 , maxDelayMs );
59-
60- // Generate random delay within the jitter range
61- long jitterRange = maxDelayMsWithJitter - minDelayMs ;
62- long actualDelayMs = minDelayMs + (jitterRange > 0 ? (long ) (RANDOM .nextDouble () * (jitterRange + 1 )) : 0 );
63-
64- return Duration .ofMillis (actualDelayMs );
43+ return calculateDelay (retryCount , RANDOM );
6544 }
6645
6746 /**
You can’t perform that action at this time.
0 commit comments