nexus-agents - v2.80.0
    Preparing search index...

    Function withRetry

    Adapters exports - Model adapters (Claude, OpenAI, Gemini, Ollama) Split from index.ts for file size compliance (Issue #285)

    • Executes an operation with retry logic using exponential backoff.

      Type Parameters

      • T

        The return type of the operation

      Parameters

      • operation: () => Promise<T>

        The async operation to execute

      • options: WithRetryOptions = {}

        Retry options (config, isRetryable predicate, onRetry callback)

      Returns Promise<Result<T, RetryExhaustedError>>

      A Result containing either the operation result or a RetryExhaustedError

      const result = await withRetry(
      () => fetchData('/api/data'),
      { config: { maxRetries: 5 } }
      );

      if (result.ok) {
      console.log(result.value);
      } else {
      console.error('All retries failed:', result.error);
      }