UNPKG

1.13 kBPlain TextView Raw
1// Copyright (c) .NET Foundation. All rights reserved.
2// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
4/** An abstraction that controls when the client attempts to reconnect and how many times it does so. */
5export interface IRetryPolicy {
6 /** Called after the transport loses the connection.
7 *
8 * @param {RetryContext} retryContext Details related to the retry event to help determine how long to wait for the next retry.
9 *
10 * @returns {number | null} The amount of time in milliseconds to wait before the next retry. `null` tells the client to stop retrying.
11 */
12 nextRetryDelayInMilliseconds(retryContext: RetryContext): number | null;
13}
14
15export interface RetryContext {
16 /**
17 * The number of consecutive failed tries so far.
18 */
19 readonly previousRetryCount: number;
20
21 /**
22 * The amount of time in milliseconds spent retrying so far.
23 */
24 readonly elapsedMilliseconds: number;
25
26 /**
27 * The error that forced the upcoming retry.
28 */
29 readonly retryReason: Error;
30}