This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

refactor: implement singleton pattern for InMemoryVectorDatabase

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>

+12 -2
+10
src/modules/search/infrastructure/InMemoryVectorDatabase.ts
··· 18 18 } 19 19 20 20 export class InMemoryVectorDatabase implements IVectorDatabase { 21 + private static instance: InMemoryVectorDatabase; 21 22 private urls: Map<string, IndexedUrl> = new Map(); 23 + 24 + private constructor() {} 25 + 26 + public static getInstance(): InMemoryVectorDatabase { 27 + if (!InMemoryVectorDatabase.instance) { 28 + InMemoryVectorDatabase.instance = new InMemoryVectorDatabase(); 29 + } 30 + return InMemoryVectorDatabase.instance; 31 + } 22 32 23 33 async indexUrl(params: IndexUrlParams): Promise<Result<void>> { 24 34 try {
+2 -2
src/shared/infrastructure/http/factories/ServiceFactory.ts
··· 311 311 const useMockVectorDb = 312 312 process.env.USE_MOCK_VECTOR_DB === 'true' || useInMemoryEvents; 313 313 const vectorDatabase: IVectorDatabase = useMockVectorDb 314 - ? new InMemoryVectorDatabase() 315 - : new InMemoryVectorDatabase(); // TODO: Replace with real vector DB implementation 314 + ? InMemoryVectorDatabase.getInstance() 315 + : InMemoryVectorDatabase.getInstance(); // TODO: Replace with real vector DB implementation 316 316 317 317 const searchService = new SearchService(vectorDatabase, metadataService); 318 318