IRetryPolicy.d.ts 933 B

123456789101112131415161718192021222324
  1. /** An abstraction that controls when the client attempts to reconnect and how many times it does so. */
  2. export interface IRetryPolicy {
  3. /** Called after the transport loses the connection.
  4. *
  5. * @param {RetryContext} retryContext Details related to the retry event to help determine how long to wait for the next retry.
  6. *
  7. * @returns {number | null} The amount of time in milliseconds to wait before the next retry. `null` tells the client to stop retrying.
  8. */
  9. nextRetryDelayInMilliseconds(retryContext: RetryContext): number | null;
  10. }
  11. export interface RetryContext {
  12. /**
  13. * The number of consecutive failed tries so far.
  14. */
  15. readonly previousRetryCount: number;
  16. /**
  17. * The amount of time in milliseconds spent retrying so far.
  18. */
  19. readonly elapsedMilliseconds: number;
  20. /**
  21. * The error that forced the upcoming retry.
  22. */
  23. readonly retryReason: Error;
  24. }