Something went wrong. Try again.
A social knowledge tool for research trails, built on ATProto semble.so
research-tool social-network tools-for-thought atproto
Something went wrong. Try again.
TypeScript
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import { Result, ok, err } from 'src/shared/core/Result';import { SyncStatus } from '../../domain/SyncStatus';import { ISyncStatusRepository } from '../../domain/repositories/ISyncStatusRepository';import { DID } from 'src/modules/user/domain/value-objects/DID';
export class InMemorySyncStatusRepository implements ISyncStatusRepository { private static instance: InMemorySyncStatusRepository; private syncStatuses: Map<string, SyncStatus> = new Map();
private constructor() {}
public static getInstance(): InMemorySyncStatusRepository { if (!InMemorySyncStatusRepository.instance) { InMemorySyncStatusRepository.instance = new InMemorySyncStatusRepository(); } return InMemorySyncStatusRepository.instance; }
async findByCuratorId(curatorId: DID): Promise<Result<SyncStatus | null>> { try { const syncStatus = this.syncStatuses.get(curatorId.value); return ok(syncStatus || null); } catch (error: any) { return err(error); } }
async findAndLockByCuratorId( curatorId: DID, ): Promise<Result<SyncStatus | null>> { // In-memory implementation doesn't need actual locking // since tests run in a single thread return this.findByCuratorId(curatorId); }
async save(syncStatus: SyncStatus): Promise<Result<void>> { try { this.syncStatuses.set(syncStatus.curatorId.value, syncStatus); return ok(undefined); } catch (error: any) { return err(error); } }
// Helper method for testing clear(): void { this.syncStatuses.clear(); }}