tero 0.1.0 → 0.3.0
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/README.md +64 -1
- package/dist/acid-engine.d.ts +224 -9
- package/dist/acid-engine.js +775 -158
- package/dist/backup.d.ts +38 -3
- package/dist/backup.js +269 -68
- package/dist/index.d.ts +51 -4
- package/dist/index.js +267 -135
- package/dist/recovery.js +2 -13
- package/dist/s3-config.d.ts +3 -0
- package/dist/s3-config.js +21 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,16 @@ interface TeroConfig {
|
|
|
6
6
|
cacheSize?: number;
|
|
7
7
|
/** Max committedBuffer entries flushed to disk per tick (prevents event loop stalls). Default: 1000. */
|
|
8
8
|
checkpointBatchSize?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Rotated WAL segments retained locally (1MB each). Default: 20.
|
|
11
|
+
*
|
|
12
|
+
* Retention is a *recovery window*, not a cache: every segment is a slice of
|
|
13
|
+
* history that a point-in-time restore can replay. With live backup enabled
|
|
14
|
+
* this only sets the floor — a segment that has not been shipped to the bucket
|
|
15
|
+
* is never pruned at all (up to the protect byte budget), so a bucket outage
|
|
16
|
+
* cannot turn a rotation into data loss.
|
|
17
|
+
*/
|
|
18
|
+
archiveKeepCount?: number;
|
|
9
19
|
/**
|
|
10
20
|
* Durability / throughput trade-off knob (like SQLite's `PRAGMA synchronous`):
|
|
11
21
|
* - 'full' (default): fsync the WAL on every commit. Max durability, ~15–60 ops/s
|
|
@@ -34,8 +44,15 @@ interface TeroConfig {
|
|
|
34
44
|
* true in production; default false for backwards compatibility.
|
|
35
45
|
*/
|
|
36
46
|
fileLock?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Durable checkpoint cadence (ms). Every interval with new commits, data files are
|
|
49
|
+
* fsynced and a durable CHECKPOINT is logged, so a restart only replays WAL written
|
|
50
|
+
* since then — boot time and memory stay bounded no matter how long the process
|
|
51
|
+
* ran. Default 30000. 0 disables (a checkpoint is still taken on close).
|
|
52
|
+
*/
|
|
53
|
+
durableCheckpointIntervalMs?: number;
|
|
37
54
|
}
|
|
38
|
-
type HydrationMode = 'lazy' | 'eager';
|
|
55
|
+
type HydrationMode = 'lazy' | 'eager' | 'off';
|
|
39
56
|
interface HydrateConfig {
|
|
40
57
|
cloudStorage: CloudStorageConfig;
|
|
41
58
|
/**
|
|
@@ -86,6 +103,8 @@ export declare class Transaction {
|
|
|
86
103
|
getAbortError(): Error | null;
|
|
87
104
|
private _checkActive;
|
|
88
105
|
create(key: string, initialData?: any): Promise<void>;
|
|
106
|
+
/** Replace the whole document within this transaction (see Tero.set). */
|
|
107
|
+
set(key: string, data: any): Promise<void>;
|
|
89
108
|
update(key: string, data: any): Promise<void>;
|
|
90
109
|
delete(key: string): Promise<void>;
|
|
91
110
|
/**
|
|
@@ -221,6 +240,18 @@ export declare class Tero {
|
|
|
221
240
|
private initializeDirectories;
|
|
222
241
|
private static readonly MAX_KEY_LENGTH;
|
|
223
242
|
private validateKey;
|
|
243
|
+
/** True when deletes/re-creates must be mirrored to the bucket (lazy/eager hydration). */
|
|
244
|
+
private cloudReconcileEnabled;
|
|
245
|
+
/**
|
|
246
|
+
* Keys known to have a tombstone in the bucket. A commit only issues the cloud
|
|
247
|
+
* tombstone DELETE for keys in this set (or with a local tombstone / pending
|
|
248
|
+
* queue entry) — previously every single commit awaited a DeleteObject.
|
|
249
|
+
* Bounded; on eviction the bucket's newest-wins rule (document vs tombstone
|
|
250
|
+
* LastModified) still keeps a later backup authoritative.
|
|
251
|
+
*/
|
|
252
|
+
private knownCloudTombstones;
|
|
253
|
+
/** Fallback when the durable queue file was lost (ENOSPC): rebuild it from local tombstones. */
|
|
254
|
+
private requeueTombstonesFromDisk;
|
|
224
255
|
private bumpGeneration;
|
|
225
256
|
private getGeneration;
|
|
226
257
|
/**
|
|
@@ -234,7 +265,14 @@ export declare class Tero {
|
|
|
234
265
|
beginTransaction(options?: TransactionOptions): Transaction;
|
|
235
266
|
private _beginTransaction;
|
|
236
267
|
private _txId;
|
|
237
|
-
|
|
268
|
+
/**
|
|
269
|
+
* Write inside a transaction. Default: deep-merge `data` into the current document.
|
|
270
|
+
* With `{ replace: true }` the document becomes exactly `data` — the only way to
|
|
271
|
+
* remove a field (a merge can add and change fields but never drop one).
|
|
272
|
+
*/
|
|
273
|
+
write(transactionId: string | Transaction, key: string, data: any, options?: {
|
|
274
|
+
replace?: boolean;
|
|
275
|
+
}): Promise<void>;
|
|
238
276
|
read(transactionId: string | Transaction, key: string, options?: {
|
|
239
277
|
lock?: 'shared' | 'exclusive';
|
|
240
278
|
}): Promise<any>;
|
|
@@ -249,6 +287,12 @@ export declare class Tero {
|
|
|
249
287
|
totalRequests: number;
|
|
250
288
|
};
|
|
251
289
|
create(key: string, initialData?: any): Promise<boolean>;
|
|
290
|
+
/**
|
|
291
|
+
* Upsert that REPLACES the whole document (creates it if absent). Unlike
|
|
292
|
+
* update(), fields missing from `data` are removed — use this whenever the
|
|
293
|
+
* caller holds the complete document (read-modify-write).
|
|
294
|
+
*/
|
|
295
|
+
set(key: string, data: any): Promise<void>;
|
|
252
296
|
update(key: string, data: any): Promise<void>;
|
|
253
297
|
/**
|
|
254
298
|
* Read a document. Returns the document data on success, or `null` if the
|
|
@@ -325,12 +369,13 @@ export declare class Tero {
|
|
|
325
369
|
batchWrite(operations: Array<{
|
|
326
370
|
key: string;
|
|
327
371
|
data: any;
|
|
372
|
+
replace?: boolean;
|
|
328
373
|
}>): Promise<void>;
|
|
329
374
|
batchRead(keys: string[]): Promise<{
|
|
330
375
|
[key: string]: any;
|
|
331
376
|
}>;
|
|
332
377
|
transferMoney(fromKey: string, toKey: string, amount: number): Promise<void>;
|
|
333
|
-
_writeRaw(transactionId: string, key: string, data: any): Promise<void>;
|
|
378
|
+
_writeRaw(transactionId: string, key: string, data: any, replace?: boolean): Promise<void>;
|
|
334
379
|
_readRaw(transactionId: string, key: string): Promise<any>;
|
|
335
380
|
_deleteRaw(transactionId: string, key: string): Promise<void>;
|
|
336
381
|
_rollbackRaw(transactionId: string): Promise<void>;
|
|
@@ -408,7 +453,9 @@ export declare class Tero {
|
|
|
408
453
|
* new directory name (disaster-recovery / staging restores). Defaults to `directory`. */
|
|
409
454
|
sourceDirectory?: string;
|
|
410
455
|
}): Promise<Tero>;
|
|
411
|
-
configureDataRecovery(config: RecoveryConfig
|
|
456
|
+
configureDataRecovery(config: RecoveryConfig & {
|
|
457
|
+
mode?: 'lazy' | 'off';
|
|
458
|
+
}): void;
|
|
412
459
|
recoverFromCloud(key: string): Promise<boolean>;
|
|
413
460
|
recoverAllFromCloud(): Promise<RecoveryResult>;
|
|
414
461
|
/** Recovery info: how many cloud files exist, which are missing locally, which can be pulled. */
|