forked from AubaidFarrukh/smart-retry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
44 lines (39 loc) · 1.06 KB
/
Copy pathtypes.ts
File metadata and controls
44 lines (39 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/** @format */
export interface RetryConfig {
maxRetries?: number;
delay?: number;
backoff?: 'exponential' | 'linear' | 'none';
shouldRetry?: (error: any) => boolean;
onRetry?: (attempt: number, error: any) => void;
/**
* By default, requests using a non-idempotent method (POST, PATCH) are not
* retried, since the server may have already processed the request before
* the response was lost. Set to `true` to retry them anyway (e.g. if your
* endpoint is safe to call multiple times, such as via an idempotency key).
*/
idempotent?: boolean;
}
export interface FailedRequest {
id: string;
url: string;
method: string;
headers?: Record<string, string>;
body?: any;
error: string;
statusCode?: number;
attempts: number;
totalDuration: number;
timestamp: string;
}
export interface RetryResult<T> {
success: boolean;
data?: T;
error?: any;
attempts: number;
totalDuration: number;
}
export interface FileStoreConfig {
maxFileSizeBytes?: number;
maxFiles?: number;
}
export type RetryableFunction<T> = () => Promise<T>;