UNPKG

@logistically/events-nestjs

Version:

NestJS integration for @logistically/events v3 - Event-driven architecture with Redis Streams

64 lines (63 loc) 1.76 kB
import { OnModuleDestroy } from '@nestjs/common'; export interface EventHandlerMetadata { methodKey: string; targetCallback: Function; eventType: string; options?: any; } export declare class EventMetadataExplorer implements OnModuleDestroy { private readonly metadataScanner; private metadataCache; private readonly cacheTTL; private cacheHits; private cacheMisses; /** * Explore an instance for event handler methods with caching * Based on NestJS microservices ListenerMetadataExplorer pattern */ explore(instance: any): EventHandlerMetadata[]; /** * Explore a single method for event handler metadata */ private exploreMethodMetadata; /** * Check if an instance has any event handlers with caching */ hasEventHandlers(instance: any): boolean; /** * Get all event types that an instance handles with caching */ getEventTypes(instance: any): string[]; /** * Check if cached data is still valid */ private isCacheValid; /** * Invalidate cache for a specific instance * Useful when instance methods are modified at runtime */ invalidateCache(instance: any): void; /** * Clear all cached data * Useful for testing or when memory usage is a concern */ clearCache(): void; /** * Get cache statistics for monitoring */ getCacheStats(): { hits: number; misses: number; hitRate: number; cacheSize: number; }; /** * Cleanup on module destroy */ onModuleDestroy(): void; /** * Pre-warm cache for known instances * Useful for frequently accessed services */ preWarmCache(instances: any[]): void; }