import { ErrorInterface, SuccessInterface } from "../../config/Interfaces/Helper/response.helper.interface"; import { TransactionMetadata } from "../../config/Interfaces/Transaction/transaction.interface"; /** * Append-only JSONL registry of in-flight transactions. * * Every mutation is one appended line; the live set is derived by replaying the file with * last-write-wins per `transactionId`. This replaces a read-parse-rewrite-fsync of the whole * registry on every register/status-change/remove - three full rewrites per transaction, each * growing with the number of concurrent transactions. * * The file is truncated whenever the replay leaves nothing live, so an append-only log of a * workload that always finishes its transactions stays at zero bytes. */ export default class TransactionRegistry { private readonly collectionPath; private readonly registryPath; private readonly transactionDir; private readonly FileManager; private readonly FolderManager; private readonly Converter; private readonly ResponseHelper; constructor(collectionPath: string); registerTransaction(metadata: TransactionMetadata): Promise; updateTransactionStatus(txnId: string, status: 'ACTIVE' | 'PREPARING' | 'COMMITTED' | 'ABORTED'): Promise; getActiveTransactions(): Promise; removeTransaction(txnId: string): Promise; /** Appends one durable JSONL record - O(1), no read and no rewrite of what came before. */ private appendRecord; /** * Replays the JSONL log into the current transaction set: last record wins per * `transactionId`, and anything whose last record is a REMOVED tombstone is dropped. * Streams line-by-line, so a long log never lands in memory whole. */ private getAllTransactions; }