tero 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acid-engine.d.ts +38 -6
- package/dist/acid-engine.js +116 -33
- package/dist/backup.d.ts +73 -0
- package/dist/backup.js +624 -64
- package/dist/index.d.ts +46 -13
- package/dist/index.js +372 -107
- package/dist/recovery.js +42 -19
- package/package.json +7 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SynchronousMode } from "./acid-engine.js";
|
|
2
2
|
import { DocumentSchema, ValidationResult } from "./schema.js";
|
|
3
|
-
import { BackupConfig, BackupMetadata, CloudStorageConfig, BucketBackupResult } from "./backup.js";
|
|
3
|
+
import { BackupConfig, BackupMetadata, CloudStorageConfig, BucketBackupResult, LiveBackupOptions, LiveBackupStatus, LiveCheckpointResult, RestoreLiveResult, BackupLogger } from "./backup.js";
|
|
4
4
|
import { RecoveryConfig, RecoveryResult, FileRecoveryInfo } from "./recovery.js";
|
|
5
5
|
interface TeroConfig {
|
|
6
6
|
directory?: string;
|
|
@@ -23,11 +23,14 @@ interface TeroConfig {
|
|
|
23
23
|
hydrateOnStartup?: HydrateConfig;
|
|
24
24
|
/** v2: a default backup config installed at construction time (use configureBackup() at runtime too). */
|
|
25
25
|
backup?: BackupConfig;
|
|
26
|
+
/** v2: per-second live WAL shipping to the bucket. RPO ≤ 1s of committed writes. */
|
|
27
|
+
liveBackup?: LiveBackupOptions;
|
|
26
28
|
/**
|
|
27
|
-
* Acquire an exclusive
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* Acquire an exclusive lock on the data directory (lock-file based:
|
|
30
|
+
* openSync 'wx' exclusive-create on <dir>/.lock with PID + stale-lock
|
|
31
|
+
* reclamation — no native modules). Two Node processes writing the same
|
|
32
|
+
* directory without this flag will corrupt each other's data. Recommended
|
|
33
|
+
* true in production; default false for backwards compatibility.
|
|
31
34
|
*/
|
|
32
35
|
fileLock?: boolean;
|
|
33
36
|
}
|
|
@@ -57,6 +60,10 @@ export declare class Transaction {
|
|
|
57
60
|
private db;
|
|
58
61
|
private startTime;
|
|
59
62
|
private opCount;
|
|
63
|
+
/** Real operation log backing getState() — the old implementation fabricated
|
|
64
|
+
* fake keys ('op_0', 'op_1', …) and labeled every operation 'write',
|
|
65
|
+
* including deletes. One array push per op: O(1), off the engine hot path. */
|
|
66
|
+
private operationsLog;
|
|
60
67
|
private destroyed;
|
|
61
68
|
private timeoutTimer?;
|
|
62
69
|
constructor(id: string, db: Tero, options?: TransactionOptions);
|
|
@@ -100,7 +107,7 @@ export declare class Tero {
|
|
|
100
107
|
*/
|
|
101
108
|
private knownKeys;
|
|
102
109
|
private readonly KNOWN_KEYS_MAX;
|
|
103
|
-
/**
|
|
110
|
+
/** Exclusive lock fd on <dir>/.lock (lock-file based; see acquireFileLock). */
|
|
104
111
|
private lockFd?;
|
|
105
112
|
/**
|
|
106
113
|
* Construct an embedded Tero instance synchronously.
|
|
@@ -181,7 +188,12 @@ export declare class Tero {
|
|
|
181
188
|
get(key: string): Promise<any>;
|
|
182
189
|
/**
|
|
183
190
|
* Map a document key to its partitioned path on disk (2-level hash-prefix).
|
|
184
|
-
*
|
|
191
|
+
* Delegates to the ENGINE'S partitionedPath() — the single authoritative
|
|
192
|
+
* implementation. The previous local FNV-1a re-implementation produced the
|
|
193
|
+
* same paths only by convention; if the two ever drifted, get() would read a
|
|
194
|
+
* different file than the engine writes (silent data loss). The engine's
|
|
195
|
+
* hash computes a 64-bit value (2 imul/char vs 1) but this runs only on
|
|
196
|
+
* cache-miss reads, which are syscall-dominated — measured impact: none.
|
|
185
197
|
*/
|
|
186
198
|
private keyToPath;
|
|
187
199
|
remove(key: string): Promise<void>;
|
|
@@ -275,6 +287,27 @@ export declare class Tero {
|
|
|
275
287
|
checkpointAndBackupToBucket(options?: {
|
|
276
288
|
tag?: string;
|
|
277
289
|
}): Promise<BucketBackupResult>;
|
|
290
|
+
/** Enable per-second live WAL shipping to the bucket. Only consistency: 'per-second'. */
|
|
291
|
+
enableLiveBackup(opts: LiveBackupOptions): void;
|
|
292
|
+
/** Stop live WAL shipping. */
|
|
293
|
+
disableLiveBackup(): void;
|
|
294
|
+
/** Current live-backup health and counters. */
|
|
295
|
+
getLiveBackupStatus(): LiveBackupStatus;
|
|
296
|
+
/** Take a checkpoint: FULL on the first call after enable (also taken
|
|
297
|
+
* automatically), INCREMENTAL (only dirty docs) on subsequent calls. */
|
|
298
|
+
liveCheckpointToBucket(opts?: {
|
|
299
|
+
tag?: string;
|
|
300
|
+
}): Promise<LiveCheckpointResult>;
|
|
301
|
+
/** Restore a fresh Tero instance from a live backup in the bucket. */
|
|
302
|
+
static restoreFromLiveBackup(opts: {
|
|
303
|
+
directory: string;
|
|
304
|
+
cloudStorage: CloudStorageConfig;
|
|
305
|
+
nodeId?: string;
|
|
306
|
+
pointInTime?: number;
|
|
307
|
+
/** Name of the ORIGINAL database directory in the bucket, if restoring to a
|
|
308
|
+
* new directory name (disaster-recovery / staging restores). Defaults to `directory`. */
|
|
309
|
+
sourceDirectory?: string;
|
|
310
|
+
}): Promise<Tero>;
|
|
278
311
|
configureDataRecovery(config: RecoveryConfig): void;
|
|
279
312
|
recoverFromCloud(key: string): Promise<boolean>;
|
|
280
313
|
recoverAllFromCloud(): Promise<RecoveryResult>;
|
|
@@ -334,11 +367,11 @@ export declare class Tero {
|
|
|
334
367
|
}>;
|
|
335
368
|
clearCache(): void;
|
|
336
369
|
/**
|
|
337
|
-
* Acquire an exclusive
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
370
|
+
* Acquire an exclusive lock on the data directory via a `.lock` file
|
|
371
|
+
* (openSync 'wx' exclusive-create — no native modules, cross-platform).
|
|
372
|
+
* The holder's PID is written to the file; if acquisition fails and the
|
|
373
|
+
* recorded PID is no longer alive, the stale lock from a crashed process
|
|
374
|
+
* is reclaimed automatically.
|
|
342
375
|
*/
|
|
343
376
|
private acquireFileLock;
|
|
344
377
|
private releaseFileLock;
|
|
@@ -372,4 +405,4 @@ export declare class Tero {
|
|
|
372
405
|
*/
|
|
373
406
|
getNewId(prefix: string): string;
|
|
374
407
|
}
|
|
375
|
-
export { DocumentSchema, ValidationResult, BackupConfig, BackupMetadata, BucketBackupResult, CloudStorageConfig, RecoveryConfig, RecoveryResult, FileRecoveryInfo, HydrateConfig };
|
|
408
|
+
export { DocumentSchema, ValidationResult, BackupConfig, BackupMetadata, BucketBackupResult, CloudStorageConfig, RecoveryConfig, RecoveryResult, FileRecoveryInfo, HydrateConfig, TeroConfig, LiveBackupOptions, LiveBackupStatus, LiveCheckpointResult, RestoreLiveResult, BackupLogger };
|