@serfab/quereus-plugin-sereus 0.10.0 → 0.11.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 +367 -361
- package/dist/cached-storage.d.ts +66 -0
- package/dist/cached-storage.js +103 -0
- package/dist/cached-storage.js.map +1 -0
- package/dist/compose-strand.d.ts +2 -2
- package/dist/compose-strand.js +18 -22
- package/dist/compose-strand.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/parse-config.js +23 -11
- package/dist/parse-config.js.map +1 -1
- package/dist/plugin-browser.js +15040 -11647
- package/dist/plugin-browser.js.map +4 -4
- package/dist/strand-schema.js +503 -503
- package/dist/types.d.ts +37 -10
- package/package.json +8 -8
- package/src/cached-storage.ts +107 -0
- package/src/cluster-size.ts +248 -248
- package/src/compose-strand.ts +21 -23
- package/src/connect-browser.ts +57 -57
- package/src/connect.ts +38 -38
- package/src/index.ts +2 -1
- package/src/parse-config.ts +70 -55
- package/src/plugin-browser.ts +29 -29
- package/src/plugin.ts +39 -39
- package/src/strand-schema.ts +533 -533
- package/src/types.ts +106 -78
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrap an embedder-supplied `IRawStorage` in `@optimystic/db-p2p`'s write-through
|
|
3
|
+
* raw-storage cache (`CachedRawStorage`) before handing it to a node or transactor.
|
|
4
|
+
*
|
|
5
|
+
* Why: bringing a control database or strand up is raw-storage-operation bound —
|
|
6
|
+
* uncached, a cold start re-reads the same handful of blocks ~2000 times (see the
|
|
7
|
+
* budget history in cadre-core's `test/control-start-storage-op-budget.spec.ts` and
|
|
8
|
+
* the sereus tickets `complete/optimystic-block-read-amplification-on-control-start`
|
|
9
|
+
* + `complete/optimystic-schema-catalog-reread-per-write-blows-storage-budgets`).
|
|
10
|
+
* Upstream ships the remedy as an opt-in wrapper — adoption is deliberately the
|
|
11
|
+
* consumer's choice — and this module is where Sereus opts in. It lives in this
|
|
12
|
+
* package (not cadre-core) for the same reason `cluster-size.ts` does: both the SQL
|
|
13
|
+
* plugin's own connectors (`composeStrand`, including the browser/IndexedDB path,
|
|
14
|
+
* where per-operation latency is highest) and cadre-core's control/strand seams
|
|
15
|
+
* need the identical wrap, and two copies could disagree.
|
|
16
|
+
*
|
|
17
|
+
* Soundness rests on the cache's single-process-owner invariant (upstream
|
|
18
|
+
* docs/storage.md §6): every write to the backend must funnel through the wrapped
|
|
19
|
+
* instance. Two rules uphold that:
|
|
20
|
+
*
|
|
21
|
+
* - **One wrap per inner instance** (WeakMap memo): the same `IRawStorage` reaches
|
|
22
|
+
* this function from several seams at once — cadre-core's node wiring and the
|
|
23
|
+
* strand backfill share the instance the node was built with, and the SQL
|
|
24
|
+
* plugin's `composeStrand` re-wraps whatever it is handed. Two live caches over
|
|
25
|
+
* one backend would each miss the other's writes; the memo makes the wrap
|
|
26
|
+
* idempotent instead — a caller wrapping an already-wrapped or already-seen
|
|
27
|
+
* instance gets the same object back.
|
|
28
|
+
* - **A Sereus process owns its data stores** — no second process writes the same
|
|
29
|
+
* backend, which is the invariant's other half.
|
|
30
|
+
*
|
|
31
|
+
* `MemoryRawStorage` is returned unwrapped on upstream's own guidance: the backend
|
|
32
|
+
* is already in-memory, so the cache adds bookkeeping with nothing to save.
|
|
33
|
+
*
|
|
34
|
+
* The memo dedupes *concurrent* seams; it is not what keeps a cache alive across a
|
|
35
|
+
* runtime rebuild. That is cadre-core's job, and it does it by OWNERSHIP: one
|
|
36
|
+
* resolved store per scope per runtime lifetime — a strand's store for the life of
|
|
37
|
+
* its instance (a hibernation quiesce → resume reuses the store already resolved,
|
|
38
|
+
* so the wake lands on a warm cache), the control store for the life of one
|
|
39
|
+
* `CadreNode.start()`. Because the store outlives the rebuild, so does its wrap,
|
|
40
|
+
* whether or not the embedder's provider returns a stable instance.
|
|
41
|
+
*
|
|
42
|
+
* When a scope's runtime stops for good, cadre-core calls {@link disposeStorageCache}
|
|
43
|
+
* — the release half of that ownership. Without it the retired wrapper's
|
|
44
|
+
* `CacheStoreHandle` would stay in the shared pool's registry for the process
|
|
45
|
+
* lifetime (`unregisterStore` is the only removal), one orphan per stop.
|
|
46
|
+
*/
|
|
47
|
+
import { type IRawStorage } from '@optimystic/db-p2p/rn';
|
|
48
|
+
/**
|
|
49
|
+
* The cached view of `storage`, memoized per instance. `label` names the store in
|
|
50
|
+
* the shared pool's `stats()` (e.g. `control`, or the strand id).
|
|
51
|
+
*/
|
|
52
|
+
export declare function wrapStorageWithCache(storage: IRawStorage, label: string): IRawStorage;
|
|
53
|
+
/**
|
|
54
|
+
* Release the cache wrapper {@link wrapStorageWithCache} returned: unregister it from
|
|
55
|
+
* the shared pool and forget the memo, so a later re-wrap of the same inner instance
|
|
56
|
+
* gets a live cache rather than this retired one. A disposed wrapper must never be
|
|
57
|
+
* handed out again — its pool store id is retired and never reused — and providers
|
|
58
|
+
* that return a stable instance per scope (the web reference app's `strand-storage.ts`,
|
|
59
|
+
* the integration harness's `captureRawStorage`) would get exactly that back on a
|
|
60
|
+
* relaunch if the memo were left in place.
|
|
61
|
+
*
|
|
62
|
+
* No-op for anything this module returned unwrapped (e.g. `MemoryRawStorage`), so
|
|
63
|
+
* callers need no `instanceof` test. Only the wrapper is released: the inner store the
|
|
64
|
+
* embedder returned is never closed — that handle stays the embedder's to manage.
|
|
65
|
+
*/
|
|
66
|
+
export declare function disposeStorageCache(storage: IRawStorage): Promise<void>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrap an embedder-supplied `IRawStorage` in `@optimystic/db-p2p`'s write-through
|
|
3
|
+
* raw-storage cache (`CachedRawStorage`) before handing it to a node or transactor.
|
|
4
|
+
*
|
|
5
|
+
* Why: bringing a control database or strand up is raw-storage-operation bound —
|
|
6
|
+
* uncached, a cold start re-reads the same handful of blocks ~2000 times (see the
|
|
7
|
+
* budget history in cadre-core's `test/control-start-storage-op-budget.spec.ts` and
|
|
8
|
+
* the sereus tickets `complete/optimystic-block-read-amplification-on-control-start`
|
|
9
|
+
* + `complete/optimystic-schema-catalog-reread-per-write-blows-storage-budgets`).
|
|
10
|
+
* Upstream ships the remedy as an opt-in wrapper — adoption is deliberately the
|
|
11
|
+
* consumer's choice — and this module is where Sereus opts in. It lives in this
|
|
12
|
+
* package (not cadre-core) for the same reason `cluster-size.ts` does: both the SQL
|
|
13
|
+
* plugin's own connectors (`composeStrand`, including the browser/IndexedDB path,
|
|
14
|
+
* where per-operation latency is highest) and cadre-core's control/strand seams
|
|
15
|
+
* need the identical wrap, and two copies could disagree.
|
|
16
|
+
*
|
|
17
|
+
* Soundness rests on the cache's single-process-owner invariant (upstream
|
|
18
|
+
* docs/storage.md §6): every write to the backend must funnel through the wrapped
|
|
19
|
+
* instance. Two rules uphold that:
|
|
20
|
+
*
|
|
21
|
+
* - **One wrap per inner instance** (WeakMap memo): the same `IRawStorage` reaches
|
|
22
|
+
* this function from several seams at once — cadre-core's node wiring and the
|
|
23
|
+
* strand backfill share the instance the node was built with, and the SQL
|
|
24
|
+
* plugin's `composeStrand` re-wraps whatever it is handed. Two live caches over
|
|
25
|
+
* one backend would each miss the other's writes; the memo makes the wrap
|
|
26
|
+
* idempotent instead — a caller wrapping an already-wrapped or already-seen
|
|
27
|
+
* instance gets the same object back.
|
|
28
|
+
* - **A Sereus process owns its data stores** — no second process writes the same
|
|
29
|
+
* backend, which is the invariant's other half.
|
|
30
|
+
*
|
|
31
|
+
* `MemoryRawStorage` is returned unwrapped on upstream's own guidance: the backend
|
|
32
|
+
* is already in-memory, so the cache adds bookkeeping with nothing to save.
|
|
33
|
+
*
|
|
34
|
+
* The memo dedupes *concurrent* seams; it is not what keeps a cache alive across a
|
|
35
|
+
* runtime rebuild. That is cadre-core's job, and it does it by OWNERSHIP: one
|
|
36
|
+
* resolved store per scope per runtime lifetime — a strand's store for the life of
|
|
37
|
+
* its instance (a hibernation quiesce → resume reuses the store already resolved,
|
|
38
|
+
* so the wake lands on a warm cache), the control store for the life of one
|
|
39
|
+
* `CadreNode.start()`. Because the store outlives the rebuild, so does its wrap,
|
|
40
|
+
* whether or not the embedder's provider returns a stable instance.
|
|
41
|
+
*
|
|
42
|
+
* When a scope's runtime stops for good, cadre-core calls {@link disposeStorageCache}
|
|
43
|
+
* — the release half of that ownership. Without it the retired wrapper's
|
|
44
|
+
* `CacheStoreHandle` would stay in the shared pool's registry for the process
|
|
45
|
+
* lifetime (`unregisterStore` is the only removal), one orphan per stop.
|
|
46
|
+
*/
|
|
47
|
+
// Imported from the `/rn` entry — the platform-neutral surface (no Node-only
|
|
48
|
+
// transports) — because `composeStrand` reaches this module on the browser path
|
|
49
|
+
// too. Both db-p2p entrypoints re-export the same storage modules, so class
|
|
50
|
+
// identity (the `instanceof` checks below) is unaffected on Node.
|
|
51
|
+
import { CachedRawStorage, MemoryRawStorage } from '@optimystic/db-p2p/rn';
|
|
52
|
+
const wraps = new WeakMap();
|
|
53
|
+
/**
|
|
54
|
+
* Reverse of `wraps`, so {@link disposeStorageCache} can evict the memo entry it
|
|
55
|
+
* cannot otherwise find — `wraps` is keyed by the inner instance, and dispose is
|
|
56
|
+
* handed the wrapper.
|
|
57
|
+
*/
|
|
58
|
+
const inners = new WeakMap();
|
|
59
|
+
/**
|
|
60
|
+
* The cached view of `storage`, memoized per instance. `label` names the store in
|
|
61
|
+
* the shared pool's `stats()` (e.g. `control`, or the strand id).
|
|
62
|
+
*/
|
|
63
|
+
export function wrapStorageWithCache(storage, label) {
|
|
64
|
+
if (storage instanceof MemoryRawStorage || storage instanceof CachedRawStorage) {
|
|
65
|
+
return storage;
|
|
66
|
+
}
|
|
67
|
+
let wrapped = wraps.get(storage);
|
|
68
|
+
if (!wrapped) {
|
|
69
|
+
wrapped = new CachedRawStorage(storage, undefined, label);
|
|
70
|
+
wraps.set(storage, wrapped);
|
|
71
|
+
inners.set(wrapped, storage);
|
|
72
|
+
}
|
|
73
|
+
return wrapped;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Release the cache wrapper {@link wrapStorageWithCache} returned: unregister it from
|
|
77
|
+
* the shared pool and forget the memo, so a later re-wrap of the same inner instance
|
|
78
|
+
* gets a live cache rather than this retired one. A disposed wrapper must never be
|
|
79
|
+
* handed out again — its pool store id is retired and never reused — and providers
|
|
80
|
+
* that return a stable instance per scope (the web reference app's `strand-storage.ts`,
|
|
81
|
+
* the integration harness's `captureRawStorage`) would get exactly that back on a
|
|
82
|
+
* relaunch if the memo were left in place.
|
|
83
|
+
*
|
|
84
|
+
* No-op for anything this module returned unwrapped (e.g. `MemoryRawStorage`), so
|
|
85
|
+
* callers need no `instanceof` test. Only the wrapper is released: the inner store the
|
|
86
|
+
* embedder returned is never closed — that handle stays the embedder's to manage.
|
|
87
|
+
*/
|
|
88
|
+
export async function disposeStorageCache(storage) {
|
|
89
|
+
if (!(storage instanceof CachedRawStorage)) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const inner = inners.get(storage);
|
|
93
|
+
if (inner) {
|
|
94
|
+
inners.delete(storage);
|
|
95
|
+
// Only evict the memo if it still points at THIS wrapper: a re-wrap after an
|
|
96
|
+
// earlier dispose has already installed a live successor we must not drop.
|
|
97
|
+
if (wraps.get(inner) === storage) {
|
|
98
|
+
wraps.delete(inner);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
await storage.dispose();
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=cached-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cached-storage.js","sourceRoot":"","sources":["../src/cached-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,6EAA6E;AAC7E,gFAAgF;AAChF,4EAA4E;AAC5E,kEAAkE;AAClE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;AAE7F,MAAM,KA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TablePluginInfo, FunctionPluginInfo, CollationPluginInfo } from '@quereus/quereus';
|
|
2
2
|
import type { Libp2p } from '@libp2p/interface';
|
|
3
3
|
import type { IRawStorage } from '@optimystic/db-p2p';
|
|
4
|
-
import type { StrandConnectionOptions, SereusPluginResult } from './types.js';
|
|
4
|
+
import type { StrandConnectionOptions, SereusPluginResult, StrandTransactor } from './types.js';
|
|
5
5
|
/** Registration shape shared by the crypto and optimystic plugin results. */
|
|
6
6
|
interface PluginRegistrations {
|
|
7
7
|
vtables?: VTablePluginInfo[];
|
|
@@ -35,7 +35,7 @@ export interface CreateNodeContext {
|
|
|
35
35
|
/** Context passed to the platform's storage-resolution strategy. */
|
|
36
36
|
export interface ResolveStorageContext {
|
|
37
37
|
strandId: string;
|
|
38
|
-
resolvedTransactor:
|
|
38
|
+
resolvedTransactor: StrandTransactor;
|
|
39
39
|
/** The storage the caller passed in `options.storage`, if any. */
|
|
40
40
|
requestedStorage?: IRawStorage;
|
|
41
41
|
}
|
package/dist/compose-strand.js
CHANGED
|
@@ -2,6 +2,7 @@ import debug from 'debug';
|
|
|
2
2
|
import optimysticPlugin from '@optimystic/quereus-plugin-optimystic/plugin';
|
|
3
3
|
import { STRAND_SCHEMA } from './strand-schema.js';
|
|
4
4
|
import { resolveStrandClusterSize } from './cluster-size.js';
|
|
5
|
+
import { wrapStorageWithCache } from './cached-storage.js';
|
|
5
6
|
const log = debug('sereus:plugin:strand');
|
|
6
7
|
const timing = debug('sereus:plugin:strand:timing');
|
|
7
8
|
/**
|
|
@@ -33,38 +34,32 @@ export function applyRegistrations(db, result) {
|
|
|
33
34
|
* vtab, hydrate the catalog, then apply the sApp schema.
|
|
34
35
|
*/
|
|
35
36
|
export async function composeStrand(db, options, platform) {
|
|
36
|
-
const { strandId, bootstrapNodes = [], schema, port = 0, enableCache = true, fretProfile = 'edge',
|
|
37
|
+
const { strandId, bootstrapNodes = [], schema, port = 0, enableCache = true, fretProfile = 'edge', transactor = 'network', } = options;
|
|
37
38
|
// Resolve (and validate) up front so a nonsense value fails before any plugin
|
|
38
39
|
// registration or node creation has happened.
|
|
39
40
|
const clusterSize = resolveStrandClusterSize(options.clusterSize);
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
if (mode !== undefined) {
|
|
45
|
-
resolvedTransactor = mode === 'bootstrap' ? 'local' : 'network';
|
|
46
|
-
}
|
|
47
|
-
else if (options.transactor !== undefined) {
|
|
48
|
-
resolvedTransactor = options.transactor;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
resolvedTransactor = 'network';
|
|
52
|
-
}
|
|
41
|
+
// The storage engine every write and read below goes through — see
|
|
42
|
+
// `StrandConnectionOptions.transactor`. Named separately from the option so
|
|
43
|
+
// the default is applied exactly once and reported on the result.
|
|
44
|
+
const resolvedTransactor = transactor;
|
|
53
45
|
const networkName = `strand-${strandId}`;
|
|
54
|
-
log('Connecting to strand %s (network: %s,
|
|
46
|
+
log('Connecting to strand %s (network: %s, transactor=%s)', strandId, networkName, resolvedTransactor);
|
|
55
47
|
// Resolve storage. Node passes `options.storage` through; the browser
|
|
56
|
-
// defaults to IndexedDB. The resolved instance feeds BOTH the
|
|
57
|
-
//
|
|
58
|
-
// front (before pluginConfig is built).
|
|
59
|
-
|
|
48
|
+
// defaults to IndexedDB. The resolved instance feeds BOTH the local
|
|
49
|
+
// transactor's `rawStorageFactory` and node creation, so it must be decided
|
|
50
|
+
// up front (before pluginConfig is built). Wrapped in the write-through
|
|
51
|
+
// raw-storage cache (cached-storage.ts) — idempotent, so a caller that
|
|
52
|
+
// already wrapped (cadre-core's seams) passes through unchanged.
|
|
53
|
+
const resolvedStorage = platform.resolveStorage
|
|
60
54
|
? await platform.resolveStorage({ strandId, resolvedTransactor, requestedStorage: options.storage })
|
|
61
55
|
: options.storage;
|
|
56
|
+
const storage = resolvedStorage ? wrapStorageWithCache(resolvedStorage, strandId) : resolvedStorage;
|
|
62
57
|
// 1. Register crypto plugin (digest, sign, verify, etc.)
|
|
63
58
|
await platform.registerCrypto(db);
|
|
64
59
|
log('Registered crypto plugin');
|
|
65
|
-
// 2. Register optimystic plugin with transactor defaults.
|
|
66
|
-
// persistent storage, hand the same instance to the plugin so
|
|
67
|
-
//
|
|
60
|
+
// 2. Register optimystic plugin with transactor defaults. On the local
|
|
61
|
+
// transactor with persistent storage, hand the same instance to the plugin so
|
|
62
|
+
// DML persists on the host backend (not in-memory).
|
|
68
63
|
const pluginConfig = {
|
|
69
64
|
default_transactor: resolvedTransactor,
|
|
70
65
|
default_key_network: 'libp2p',
|
|
@@ -185,6 +180,7 @@ export async function composeStrand(db, options, platform) {
|
|
|
185
180
|
functions: [],
|
|
186
181
|
collations: [],
|
|
187
182
|
hydrated,
|
|
183
|
+
transactor: resolvedTransactor,
|
|
188
184
|
async shutdown() {
|
|
189
185
|
log('Shutting down strand connection %s', strandId);
|
|
190
186
|
await collectionFactory.shutdown();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose-strand.js","sourceRoot":"","sources":["../src/compose-strand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,gBAAgB,MAAM,8CAA8C,CAAC;AAK5E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"compose-strand.js","sourceRoot":"","sources":["../src/compose-strand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,gBAAgB,MAAM,8CAA8C,CAAC;AAK5E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,GAAG,GAAG,KAAK,CAAC,sBAAsB,CA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MAAM,iBAAiB,CAAC,QAAQ,EAAE,CAAC;QACnC,IAAI,WAAW,EAAE,CAAC;YACjB,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;QAC1B,CAAC;QACD,MAAM,GAAG,CAAC;IACX,CAAC;IAED,4EAA4E;IAC5E,8EAA8E;IAC9E,sEAAsE;IACtE,2EAA2E;IAC3E,8EAA8E;IAC9E,8EAA8E;IAC9E,+EAA+E;IAC/E,qEAAqE;IACrE,OAAO;QACN,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,EAAE;QACb,UAAU,EAAE,EAAE;QACd,QAAQ;QACR,UAAU,EAAE,kBAAkB;QAC9B,KAAK,CAAC,QAAQ;YACb,GAAG,CAAC,oCAAoC,EAAE,QAAQ,CAAC,CAAC;YACpD,MAAM,iBAAiB,CAAC,QAAQ,EAAE,CAAC;YACnC,IAAI,WAAW,EAAE,CAAC;gBACjB,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;YAC1B,CAAC;YACD,GAAG,CAAC,gCAAgC,EAAE,QAAQ,CAAC,CAAC;QACjD,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { connectToStrand } from './connect.js';
|
|
2
2
|
export { MIN_CLUSTER_SIZE, CONTROL_REPLICATION_BREADTH, CONTROL_CLUSTER_POLICY, DEFAULT_STRAND_CLUSTER_SIZE, STRAND_CLUSTER_POLICY, resolveStrandClusterSize } from './cluster-size.js';
|
|
3
|
-
export
|
|
3
|
+
export { wrapStorageWithCache, disposeStorageCache } from './cached-storage.js';
|
|
4
|
+
export type { StrandConnectionOptions, SereusPluginResult, StrandTransactor } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { connectToStrand } from './connect.js';
|
|
2
2
|
export { MIN_CLUSTER_SIZE, CONTROL_REPLICATION_BREADTH, CONTROL_CLUSTER_POLICY, DEFAULT_STRAND_CLUSTER_SIZE, STRAND_CLUSTER_POLICY, resolveStrandClusterSize } from './cluster-size.js';
|
|
3
|
+
export { wrapStorageWithCache, disposeStorageCache } from './cached-storage.js';
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACN,gBAAgB,EAChB,2BAA2B,EAC3B,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACN,gBAAgB,EAChB,2BAA2B,EAC3B,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/parse-config.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
const STRAND_TRANSACTORS = ['local', 'network', 'test'];
|
|
2
|
+
/**
|
|
3
|
+
* Read the optional `transactor` key. Unlike `fret_profile` (whose unknown
|
|
4
|
+
* values fall back to the default), an unrecognised transactor throws: silently
|
|
5
|
+
* running on the network when the caller asked for local storage is the kind of
|
|
6
|
+
* mistake that only surfaces as a mysterious hang on a machine with no peers.
|
|
7
|
+
*/
|
|
8
|
+
function parseTransactor(raw) {
|
|
9
|
+
if (raw === undefined || raw === null || raw === '')
|
|
10
|
+
return undefined;
|
|
11
|
+
if (typeof raw !== 'string' || !STRAND_TRANSACTORS.includes(raw)) {
|
|
12
|
+
throw new Error(`quereus-plugin-sereus: transactor must be one of ${STRAND_TRANSACTORS.join(', ')} (got ${JSON.stringify(raw)})`);
|
|
13
|
+
}
|
|
14
|
+
return raw;
|
|
15
|
+
}
|
|
1
16
|
/**
|
|
2
17
|
* Parse the plugin-loader SqlValue config into typed StrandConnectionOptions.
|
|
3
18
|
* Shared by the Node (`plugin.ts`) and browser (`plugin-browser.ts`) entries.
|
|
@@ -17,16 +32,14 @@ export function parseConfig(config) {
|
|
|
17
32
|
const port = typeof config.port === 'number' ? config.port : 0;
|
|
18
33
|
const enableCache = config.enable_cache !== false && config.enable_cache !== 0;
|
|
19
34
|
const fretProfile = config.fret_profile === 'core' ? 'core' : 'edge';
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
? config.transactor
|
|
29
|
-
: undefined;
|
|
35
|
+
// Storage engine — see `StrandConnectionOptions.transactor`. Left out entirely
|
|
36
|
+
// when unset so `composeStrand` applies its own default.
|
|
37
|
+
const transactor = parseTransactor(config.transactor);
|
|
38
|
+
// NOTE: `parseConfig` reads the keys it knows and ignores every other key in
|
|
39
|
+
// the map — there is no allowlist, so a misspelled or retired setting (e.g.
|
|
40
|
+
// the `mode` this package used to carry) is silently dropped rather than
|
|
41
|
+
// rejected. Deliberate: the plugin loader hands through whatever the host's
|
|
42
|
+
// settings file holds.
|
|
30
43
|
// NOTE: persistent storage cannot ride a `Record<string, SqlValue>` — an
|
|
31
44
|
// `IRawStorage` is not an `SqlValue`. The Node loader (`plugin.ts`) reads the
|
|
32
45
|
// platform-only `storage_path` key directly and resolves it to a concrete
|
|
@@ -40,7 +53,6 @@ export function parseConfig(config) {
|
|
|
40
53
|
port,
|
|
41
54
|
enableCache,
|
|
42
55
|
fretProfile,
|
|
43
|
-
...(mode && { mode }),
|
|
44
56
|
...(transactor && { transactor }),
|
|
45
57
|
};
|
|
46
58
|
}
|
package/dist/parse-config.js.map
CHANGED
|
@@ -1 +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