import { OnApplicationShutdown } from '@nestjs/common'; import { ApiErrorType } from '../api.connection.error'; import { IApiConnectionSpecific } from '../api.service'; export interface ConnectionPoolItem { endpoint: string; primary: boolean; performanceScore: number; backoffDelay: number; failureCount: number; rateLimited: boolean; failed: boolean; lastRequestTime: number; connected: boolean; timeoutId?: NodeJS.Timeout; } export interface IConnectionPoolStateManager> { addToConnections(endpoint: string, primary: boolean, initFailed: boolean): Promise; getNextConnectedEndpoint(connectedEndpoints?: string[]): Promise; getFieldValue>(endpoint: string, field: K): Promise[K]>; setFieldValue>(endpoint: string, field: K, value: ConnectionPoolItem[K]): Promise; getSuspendedEndpoints(): Promise; removeFromConnections(endpoint: string): Promise; handleApiError(endpoint: string, errorType: ApiErrorType): Promise; handleApiSuccess(endpoint: string, responseTime: number): Promise; getDisconnectedEndpoints(): Promise; } export declare class ConnectionPoolStateManager> implements OnApplicationShutdown { private onAllConnectionsRemoved; private pool; /** * @param onAllConnectionsRemoved - allows overwritting the behaviour when all connections are removed * */ constructor(onAllConnectionsRemoved?: () => void); addToConnections(endpoint: string, primary: boolean): Promise; logConnectionStatus(): void; getNextConnectedEndpoint(connectedEndpoints?: string[]): Promise; private getPrimaryEndpoint; get numConnections(): number; getFieldValue>(endpoint: string, field: K): Promise[K]>; setFieldValue>(endpoint: string, field: K, value: ConnectionPoolItem[K]): Promise; getSuspendedEndpoints(): Promise; setRecoverTimeout(endpoint: string, delay: number): Promise; clearTimeout(endpoint: string): Promise; removeFromConnections(endpoint: string): Promise; onApplicationShutdown(): Promise; handleApiError(endpoint: string, errorType: ApiErrorType): Promise; private calculateNextDelay; private calculatePerformanceScore; handleApiSuccess(endpoint: string, responseTime: number): Promise; handleBatchApiSuccess(successResults: Array<{ endpoint: string; responseTime: number; }>): Promise; handleBatchApiError(errorResults: Array<{ endpoint: string; errorType: ApiErrorType; }>): Promise; getDisconnectedEndpoints(): Promise; }