firestore-retry
Version:
A robust retry mechanism for Firebase Firestore operations with exponential backoff and configurable retry strategies
46 lines • 1.77 kB
TypeScript
import * as admin from 'firebase-admin';
export interface RetryConfig {
maxRetries?: number;
baseDelay?: number;
maxDelay?: number;
jitterFactor?: number;
}
export declare const isRetryableFirestoreError: (error: any) => boolean;
export declare const retryOperation: <T>(operation: () => Promise<T>, operationName?: string, config?: RetryConfig) => Promise<T>;
export declare const retryFirestoreBatchCommit: (batch: admin.firestore.WriteBatch, config?: RetryConfig) => Promise<void>;
export declare const retryFirestoreOperation: <T>(operation: () => Promise<T>, operationName?: string, config?: RetryConfig) => Promise<T>;
export declare class RetryableBatch {
private batch;
private config;
private operationCount;
constructor(config?: RetryConfig);
set(docRef: admin.firestore.DocumentReference, data: any, options?: admin.firestore.SetOptions): this;
update(docRef: admin.firestore.DocumentReference, data: any): this;
delete(docRef: admin.firestore.DocumentReference): this;
commit(): Promise<void>;
getOperationCount(): number;
}
export declare const createRetryableBatch: (config?: RetryConfig) => RetryableBatch;
export declare const RetryConfigs: {
readonly FAST: {
readonly maxRetries: 3;
readonly baseDelay: 500;
readonly maxDelay: 5000;
};
readonly STANDARD: {
readonly maxRetries: 5;
readonly baseDelay: 1000;
readonly maxDelay: 30000;
};
readonly AGGRESSIVE: {
readonly maxRetries: 10;
readonly baseDelay: 1000;
readonly maxDelay: 60000;
};
readonly PATIENT: {
readonly maxRetries: 7;
readonly baseDelay: 2000;
readonly maxDelay: 120000;
};
};
//# sourceMappingURL=retry.d.ts.map