@rulvar/store-sqlite 1.35.0 → 1.37.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/dist/index.d.ts +14 -1
- package/dist/index.js +12 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,14 @@ declare const DEFAULT_LEASE_TTL_MS = 6e4;
|
|
|
6
6
|
interface SqliteStoreOptions {
|
|
7
7
|
/** Database file path, or ':memory:' for an in-process store. */
|
|
8
8
|
path: string;
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Lease ttl; default the Appendix A interim reference (60000 ms). An
|
|
11
|
+
* integer between 1 and 2147483647 ms (workers renew on Node timers at
|
|
12
|
+
* ttl/3), refused as a ConfigError BEFORE the database opens: zero or
|
|
13
|
+
* a negative made every lease born expired (a second owner could take
|
|
14
|
+
* over immediately), NaN failed the first acquire with a raw sqlite
|
|
15
|
+
* NOT NULL error, and Infinity never expired (v1.35.0 review P2-4).
|
|
16
|
+
*/
|
|
10
17
|
ttlMs?: number;
|
|
11
18
|
/** Injectable clock for lease-expiry tests. */
|
|
12
19
|
now?: () => number;
|
|
@@ -26,6 +33,12 @@ declare class SqliteStore implements MetaLookupStore, LeasableStore {
|
|
|
26
33
|
getMeta(runId: string): Promise<RunMeta | undefined>;
|
|
27
34
|
listRuns(f?: RunFilter): Promise<RunMeta[]>;
|
|
28
35
|
delete(runId: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* TTL introspection (the LeasableStore optional capability): lets
|
|
38
|
+
* createWorker verify at construction that its renew cadence matches
|
|
39
|
+
* this store's expiry instead of trusting two config sources to agree.
|
|
40
|
+
*/
|
|
41
|
+
get leaseTtlMs(): number;
|
|
29
42
|
acquire(runId: string, owner: string): Promise<Lease>;
|
|
30
43
|
renew(l: Lease): Promise<void>;
|
|
31
44
|
release(l: Lease): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DatabaseSync } from "node:sqlite";
|
|
2
|
-
import { JournalOrderViolation, LeaseHeldError, metaMatchesFilter } from "@rulvar/core";
|
|
2
|
+
import { ConfigError, JournalOrderViolation, LeaseHeldError, metaMatchesFilter } from "@rulvar/core";
|
|
3
3
|
//#region src/store.ts
|
|
4
4
|
/**
|
|
5
5
|
* SqliteStore (M5-T02): JournalStore plus LeasableStore with fencing
|
|
@@ -29,8 +29,10 @@ var SqliteStore = class {
|
|
|
29
29
|
ttlMs;
|
|
30
30
|
now;
|
|
31
31
|
constructor(options) {
|
|
32
|
+
const ttlMs = options.ttlMs ?? 6e4;
|
|
33
|
+
if (!Number.isInteger(ttlMs) || ttlMs < 1 || ttlMs > 2147483647) throw new ConfigError(`SqliteStoreOptions.ttlMs must be an integer between 1 and 2147483647 ms (workers renew on Node timers at ttl/3); got ${String(ttlMs)}`);
|
|
32
34
|
this.db = new DatabaseSync(options.path);
|
|
33
|
-
this.ttlMs =
|
|
35
|
+
this.ttlMs = ttlMs;
|
|
34
36
|
this.now = options.now ?? wallClock;
|
|
35
37
|
this.db.exec(`
|
|
36
38
|
PRAGMA journal_mode = WAL;
|
|
@@ -124,6 +126,14 @@ var SqliteStore = class {
|
|
|
124
126
|
throw thrown;
|
|
125
127
|
}
|
|
126
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* TTL introspection (the LeasableStore optional capability): lets
|
|
131
|
+
* createWorker verify at construction that its renew cadence matches
|
|
132
|
+
* this store's expiry instead of trusting two config sources to agree.
|
|
133
|
+
*/
|
|
134
|
+
get leaseTtlMs() {
|
|
135
|
+
return this.ttlMs;
|
|
136
|
+
}
|
|
127
137
|
async acquire(runId, owner) {
|
|
128
138
|
this.db.exec("BEGIN IMMEDIATE");
|
|
129
139
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/store-sqlite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.0",
|
|
4
4
|
"description": "Rulvar SQLite store implementing JournalStore and LeasableStore with a fencing epoch.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@rulvar/core": "1.
|
|
25
|
+
"@rulvar/core": "1.37.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^22.20.0",
|
|
29
29
|
"tsdown": "^0.22.3",
|
|
30
30
|
"typescript": "~6.0.3",
|
|
31
|
-
"@rulvar/store-conformance": "1.
|
|
31
|
+
"@rulvar/store-conformance": "1.37.0"
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|