UNPKG

edgevector-db-sdk

Version:

Official TypeScript/JavaScript SDK for EdgeVector DB - A globally distributed, edge-native database platform combining document storage, vector search, time series, and real-time streaming

128 lines 2.96 kB
/** * HTTP Client with retry logic, connection pooling, and performance optimizations */ import { EventEmitter } from 'eventemitter3'; import { EdgeVectorConfig, PerformanceMetrics } from '../types'; export interface RequestOptions { method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; headers?: Record<string, string>; body?: any; timeout?: number; retries?: number; priority?: number; cache?: boolean; streaming?: boolean; } export interface RequestContext { id: string; url: string; method: string; startTime: number; endTime?: number; duration?: number; size?: number; cached?: boolean; retryCount?: number; error?: Error; } /** * High-performance HTTP client with built-in retries, connection pooling, and caching */ export declare class HttpClient extends EventEmitter { private config; private queue; private cache; private metrics; private requestCounter; private connections; constructor(config: EdgeVectorConfig); /** * Make an HTTP request with automatic retries and connection pooling */ request<T = any>(endpoint: string, options?: RequestOptions): Promise<T>; /** * Execute the actual HTTP request with retries */ private executeRequest; /** * Perform the actual HTTP request */ private performRequest; /** * Build request headers with authentication */ private buildHeaders; /** * Build full URL from endpoint */ private buildUrl; /** * Generate cache key for request */ private getCacheKey; /** * Get data from cache */ private getFromCache; /** * Set data in cache */ private setCache; /** * Create appropriate error based on HTTP response */ private createHttpError; /** * Handle and transform errors */ private handleHttpError; /** * Get retry configuration */ private getRetryConfig; /** * Generate unique request ID */ private generateRequestId; /** * Get response size for metrics */ private getResponseSize; /** * Sanitize headers for logging (remove sensitive data) */ private sanitizeHeaders; /** * Update success metrics */ private updateSuccessMetrics; /** * Update error metrics */ private updateErrorMetrics; /** * Update cache metrics */ private updateCacheMetrics; /** * Set up metrics collection */ private setupMetricsCollection; /** * Collect and emit performance metrics */ private collectMetrics; /** * Get current performance metrics */ getMetrics(): PerformanceMetrics; /** * Clear cache */ clearCache(): void; /** * Close all connections and cleanup */ close(): Promise<void>; } //# sourceMappingURL=http-client.d.ts.map