1. /**
  2. * Configuration object for time-based retry intervals.
  3. */
  4. const retryConfig = {
  5. /**
  6. * Initial retry interval in milliseconds.
  7. * @type {number}
  8. */
  9. initialInterval: 1000, // 1 second
  10. /**
  11. * Maximum retry interval in milliseconds.
  12. * @type {number}
  13. */
  14. maxInterval: 60000, // 60 seconds
  15. /**
  16. * Number of retries before giving up.
  17. * @type {number}
  18. */
  19. maxRetries: 5,
  20. /**
  21. * Time to wait before starting exponential backoff.
  22. * @type {number}
  23. */
  24. backoffDelay: 1000, // 1 second
  25. /**
  26. * Function to calculate the next retry interval based on the number of retries.
  27. * @param {number} retryCount The current retry count.
  28. * @returns {number} The next retry interval in milliseconds.
  29. */
  30. getNextInterval: function(retryCount) {
  31. return Math.min(
  32. this.maxInterval,
  33. this.initialInterval * Math.pow(2, retryCount) + this.backoffDelay
  34. );
  35. }
  36. };
  37. // Export the configuration object (optional, depending on usage)
  38. // export default retryConfig;

Add your comment