harperdb
Version:
HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.
64 lines (63 loc) • 1.88 kB
TypeScript
import type { RootDatabase, Transaction as LMDBTransaction } from 'lmdb';
import type { Context } from './ResourceInterface.ts';
export declare const TRANSACTION_STATE: {
CLOSED: number;
OPEN: number;
LINGERING: number;
};
export declare function replicationConfirmation(callback: any): void;
declare class StartedTransaction extends Error {
}
export declare class DatabaseTransaction implements Transaction {
#private;
writes: any[];
lmdbDb: RootDatabase;
readTxn: LMDBTransaction;
readTxnRefCount: number;
readTxnsUsed: number;
timeout: number;
validated: number;
timestamp: number;
next: DatabaseTransaction;
stale: boolean;
startedFrom?: {
resourceName: string;
method: string;
};
stackTraces?: StartedTransaction[];
overloadChecked: boolean;
open: number;
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 {};