harperdb
Version:
HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.
56 lines (55 loc) • 1.87 kB
TypeScript
import { RootDatabase, Transaction as LMDBTransaction } from 'lmdb';
import type { Context } from './ResourceInterface';
export declare enum TRANSACTION_STATE {
CLOSED = 0,// the transaction has been committed or aborted and can no longer be used for writes (if read txn is active, it can be used for reads)
OPEN = 1,// the transaction is open and can be used for reads and writes
LINGERING = 2
}
export declare function replicationConfirmation(callback: any): void;
export declare class DatabaseTransaction implements Transaction {
#private;
writes: any[];
lmdbDb: RootDatabase;
readTxn: LMDBTransaction;
readTxnRefCount: number;
readTxnsUsed: number;
validated: number;
timestamp: number;
next: DatabaseTransaction;
stale: boolean;
overloadChecked: boolean;
open: TRANSACTION_STATE;
getReadTxn(): LMDBTransaction | void;
useReadTxn(): LMDBTransaction;
doneReadTxn(): void;
disregardReadTxn(): void;
checkOverloaded(): void;
addWrite(operation: any): Promise<CommitResolution>;
removeWrite(operation: any): void;
/**
* Resolves with information on the timestamp and success of the commit
*/
commit(options?: {
doneWriting?: boolean;
timestamp?: number;
}): Promise<CommitResolution>;
abort(): void;
getContext(): Context;
setContext(context: any): void;
}
interface CommitResolution {
txnTime: number;
next?: CommitResolution;
}
export interface Transaction {
commit(options: any): Promise<CommitResolution>;
abort?(flush?: boolean): any;
}
export declare class ImmediateTransaction extends DatabaseTransaction {
_timestamp: number;
addWrite(operation: any): void;
get timestamp(): any;
getReadTxn(): void;
}
export declare function setTxnExpiration(ms: any): Set<DatabaseTransaction>;
export {};