= $maxAttempts || !$this->shouldRetry($e, $retryableExceptions)) { throw $e; } $delay = (int) ($initialDelayMs * (2 ** ($attempt - 1))); $jitter = (int) ($delay * $jitterFactor * (random_int(0, 100) / 100)); $wait = $delay + $jitter; usleep($wait * 1000); // usleep menggunakan mikrosdetik } } throw $lastException ?? new \RuntimeException('Operasi retry gagal tanpa exception spesifik.'); } private function shouldRetry(Throwable $e, array $retryableExceptions): bool { if (empty($retryableExceptions)) { return true; // Selalu retry jika daftar kosong } foreach ($retryableExceptions as $retryable) { if ($e instanceof $retryable) { return true; } } return false; } }