hikma-engine
Version:
Code Knowledge Graph Indexer - A sophisticated TypeScript-based indexer that transforms Git repositories into multi-dimensional knowledge stores for AI agents
48 lines • 1.98 kB
TypeScript
/**
* Performance optimization service for the API
* Handles caching, connection pooling, and performance monitoring
*/
export interface CacheOptions {
ttl?: number;
maxSize?: number;
updateAgeOnGet?: boolean;
}
export interface PerformanceMetrics {
cacheHitRate: number;
averageResponseTime: number;
memoryUsage: NodeJS.MemoryUsage;
activeConnections: number;
queuedRequests: number;
}
export declare class PerformanceOptimizer {
private static instance;
private caches;
private connectionPools;
private requestQueue;
private activeRequests;
private responseTimeHistory;
private cacheStats;
private constructor();
static getInstance(): PerformanceOptimizer;
private initializeCaches;
private initializeConnectionPools;
private startPerformanceMonitoring;
getFromCache<T>(cacheType: string, key: string, fallbackFn?: () => Promise<T>, options?: CacheOptions): Promise<T | null>;
setCache(cacheType: string, key: string, value: any, options?: CacheOptions): void;
invalidateCache(cacheType: string, key?: string): void;
getCacheStats(cacheType?: string): Record<string, any>;
queueRequest<T>(requestId: string, requestFn: () => Promise<T>, priority?: number): Promise<T>;
private getMaxConcurrentRequests;
private recordResponseTime;
private optimizeMemoryUsage;
private cleanupExpiredData;
getPerformanceMetrics(): PerformanceMetrics;
private collectPerformanceMetrics;
getConnection(poolName: string): Promise<any>;
releaseConnection(poolName: string, connection: any): void;
batchProcess<T, R>(items: T[], processFn: (batch: T[]) => Promise<R[]>, batchSize?: number): Promise<R[]>;
streamResults<T>(dataSource: () => AsyncIterable<T>, chunkSize?: number): AsyncGenerator<T[], void, unknown>;
destroy(): void;
}
export declare const performanceOptimizer: PerformanceOptimizer;
//# sourceMappingURL=performance-optimizer.d.ts.map