@harperfast/rocksdb-js 0.1.5 → 0.1.7
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 +20 -6
- package/dist/index.cjs +8 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -5
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +8 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +41 -41
package/README.md
CHANGED
|
@@ -217,7 +217,7 @@ synchronously instead of returning a promise.
|
|
|
217
217
|
|
|
218
218
|
```typescript
|
|
219
219
|
const result = db.get('foo');
|
|
220
|
-
const value = result instanceof Promise ?
|
|
220
|
+
const value = result instanceof Promise ? await result : result;
|
|
221
221
|
assert.equal(result, 'foo');
|
|
222
222
|
```
|
|
223
223
|
|
|
@@ -675,11 +675,11 @@ available.
|
|
|
675
675
|
await Promise.all([
|
|
676
676
|
db.withLock('key', () => {
|
|
677
677
|
console.log('first lock blocking for 100ms');
|
|
678
|
-
return new Promise(resolve => setTimeout(resolve, 100));
|
|
678
|
+
return new Promise((resolve) => setTimeout(resolve, 100));
|
|
679
679
|
}),
|
|
680
680
|
db.withLock('key', () => {
|
|
681
681
|
console.log('second lock blocking for 100ms');
|
|
682
|
-
return new Promise(resolve => setTimeout(resolve, 100));
|
|
682
|
+
return new Promise((resolve) => setTimeout(resolve, 100));
|
|
683
683
|
}),
|
|
684
684
|
db.withLock('key', () => {
|
|
685
685
|
console.log('third lock acquired');
|
|
@@ -713,6 +713,9 @@ db.flushSync();
|
|
|
713
713
|
A user controlled API for logging transactions. This API is designed to be generic so that you can
|
|
714
714
|
log gets, puts, and deletes, but also arbitrary entries.
|
|
715
715
|
|
|
716
|
+
Transaction logs are isolated by the database path allowing different column families in the same
|
|
717
|
+
database to share the transaction log store, but not other databases.
|
|
718
|
+
|
|
716
719
|
### `db.listLogs(): string[]`
|
|
717
720
|
|
|
718
721
|
Returns an array of log store names.
|
|
@@ -726,6 +729,7 @@ const names = db.listLogs();
|
|
|
726
729
|
Deletes transaction log files older than the `transactionLogRetention` (defaults to 3 days).
|
|
727
730
|
|
|
728
731
|
- `options: object`
|
|
732
|
+
- `before?: number` Remove all transaction log files older than the specified timestamp.
|
|
729
733
|
- `destroy?: boolean` When `true`, deletes transaction log stores including all log sequence files
|
|
730
734
|
on disk.
|
|
731
735
|
- `name?: string` The name of a store to limit the purging to.
|
|
@@ -768,6 +772,7 @@ to disk right before the transaction is committed. You may add multiple enties p
|
|
|
768
772
|
underlying architecture is thread safe.
|
|
769
773
|
|
|
770
774
|
- `log.addEntry()`
|
|
775
|
+
- `log.path`
|
|
771
776
|
- `log.query()`
|
|
772
777
|
|
|
773
778
|
#### `log.addEntry(data, transactionId): void`
|
|
@@ -799,6 +804,15 @@ Note that the `TransactionLog` class also has internal methods `_getMemoryMapOfF
|
|
|
799
804
|
`_findPosition`, and `_getLastCommittedPosition` that should not be used directly and may change in
|
|
800
805
|
any version.
|
|
801
806
|
|
|
807
|
+
#### `log.path: string`
|
|
808
|
+
|
|
809
|
+
Returns the path to the transaction log store files.
|
|
810
|
+
|
|
811
|
+
```typescript
|
|
812
|
+
const log = db.useLog('foo');
|
|
813
|
+
console.log(log.path);
|
|
814
|
+
```
|
|
815
|
+
|
|
802
816
|
#### `log.query(options?): IterableIterator<TransactionLogEntry>`
|
|
803
817
|
|
|
804
818
|
Returns an iterable/iterator that streams all log entries for the given filter.
|
|
@@ -838,7 +852,7 @@ for (const entry of iter) {
|
|
|
838
852
|
console.log(entry);
|
|
839
853
|
}
|
|
840
854
|
|
|
841
|
-
const lastHour = Date.now() -
|
|
855
|
+
const lastHour = Date.now() - 60 * 60 * 1000;
|
|
842
856
|
const rangeIter = log.query({ start: lastHour, end: Date.now() });
|
|
843
857
|
for (const entry of rangeIter) {
|
|
844
858
|
console.log(entry.timestamp, entry.data);
|
|
@@ -879,11 +893,11 @@ Returns an array containing that status of all active RocksDB instances.
|
|
|
879
893
|
|
|
880
894
|
- `path: string` The database path.
|
|
881
895
|
- `refCount: number` The number of JavaScript database instances plus the registry's reference.
|
|
882
|
-
- `columnFamiles:
|
|
896
|
+
- `columnFamiles: object` A map of column family names and their their info.
|
|
897
|
+
- `userSharedBuffers: number` The count of active user shared buffers.
|
|
883
898
|
- `transactions: number` The count of active transactions.
|
|
884
899
|
- `closables: number` The count of active database, transactions, and iterators.
|
|
885
900
|
- `locks: number` The count of active locks.
|
|
886
|
-
- `userSharedBuffers: number` The count of active user shared buffers.
|
|
887
901
|
- `listenerCallbacks: number` The count of in-flight callbacks.
|
|
888
902
|
|
|
889
903
|
```typescript
|
package/dist/index.cjs
CHANGED
|
@@ -31,10 +31,10 @@ let node_fs = require("node:fs");
|
|
|
31
31
|
let node_module = require("node:module");
|
|
32
32
|
let node_path = require("node:path");
|
|
33
33
|
let node_url = require("node:url");
|
|
34
|
-
let msgpackr = require("msgpackr");
|
|
35
34
|
let ordered_binary = require("ordered-binary");
|
|
36
35
|
ordered_binary = __toESM(ordered_binary);
|
|
37
36
|
let _harperfast_extended_iterable = require("@harperfast/extended-iterable");
|
|
37
|
+
let msgpackr = require("msgpackr");
|
|
38
38
|
|
|
39
39
|
//#region src/load-binding.ts
|
|
40
40
|
const nativeExtRE = /\.node$/;
|
|
@@ -63,7 +63,12 @@ function locateBinding() {
|
|
|
63
63
|
const report = process.report.getReport();
|
|
64
64
|
isMusl = (!report?.header || !report.header.glibcVersionRuntime) && Array.isArray(report?.sharedObjects) && report.sharedObjects.some((obj) => obj.includes("libc.musl-") || obj.includes("ld-musl-"));
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
try {
|
|
67
|
+
isMusl = isMusl || (0, node_child_process.execSync)("ldd --version", {
|
|
68
|
+
encoding: "utf8",
|
|
69
|
+
stdio: "pipe"
|
|
70
|
+
}).includes("musl");
|
|
71
|
+
} catch {}
|
|
67
72
|
}
|
|
68
73
|
runtime = isMusl ? "-musl" : "-glibc";
|
|
69
74
|
}
|
|
@@ -1811,7 +1816,7 @@ function loadLastPosition(transactionLog, readUncommitted) {
|
|
|
1811
1816
|
//#region src/index.ts
|
|
1812
1817
|
const versions = {
|
|
1813
1818
|
rocksdb: version,
|
|
1814
|
-
"rocksdb-js": "0.1.
|
|
1819
|
+
"rocksdb-js": "0.1.7"
|
|
1815
1820
|
};
|
|
1816
1821
|
|
|
1817
1822
|
//#endregion
|