@powerhousedao/reactor 6.2.2-dev.3 → 6.2.2-dev.5
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/{build-worker-executor-BDrPlCJl.js → build-worker-executor--nhFRF47.js} +2 -2
- package/dist/{build-worker-executor-BDrPlCJl.js.map → build-worker-executor--nhFRF47.js.map} +1 -1
- package/dist/entry.js +1 -1
- package/dist/index.d.ts +93 -62
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +172 -102
- package/dist/index.js.map +1 -1
- package/dist/projection-entry.js +1 -1
- package/dist/worker-handle-B1w03nRA.js.map +1 -1
- package/package.json +4 -4
|
@@ -39,7 +39,7 @@ async function buildWorkerExecutor(options) {
|
|
|
39
39
|
const registry = new DocumentModelRegistry();
|
|
40
40
|
await loadModelManifest(init.models, loadFactory, registry, logger);
|
|
41
41
|
let signatureVerifier;
|
|
42
|
-
try {
|
|
42
|
+
if (init.signatureVerifier) try {
|
|
43
43
|
signatureVerifier = await loadFactory(init.signatureVerifier);
|
|
44
44
|
} catch (error) {
|
|
45
45
|
logger.error("worker failed to load signature verifier: @spec @error", init.signatureVerifier, error);
|
|
@@ -80,4 +80,4 @@ async function buildWorkerExecutor(options) {
|
|
|
80
80
|
//#endregion
|
|
81
81
|
export { defaultLoadFactory as n, buildWorkerExecutor as t };
|
|
82
82
|
|
|
83
|
-
//# sourceMappingURL=build-worker-executor
|
|
83
|
+
//# sourceMappingURL=build-worker-executor--nhFRF47.js.map
|
package/dist/{build-worker-executor-BDrPlCJl.js.map → build-worker-executor--nhFRF47.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-worker-executor
|
|
1
|
+
{"version":3,"file":"build-worker-executor--nhFRF47.js","names":[],"sources":["../src/executor/worker/build-worker-executor.ts"],"sourcesContent":["import type {\n DocumentModelModule,\n OperationWithContext,\n} from \"@powerhousedao/shared/document-model\";\nimport type { ILogger } from \"document-model\";\nimport type { Kysely } from \"kysely\";\nimport { CollectionMembershipCache } from \"../../cache/collection-membership-cache.js\";\nimport { DocumentMetaCache } from \"../../cache/document-meta-cache.js\";\nimport { KyselyOperationIndex } from \"../../cache/kysely-operation-index.js\";\nimport { KyselyWriteCache } from \"../../cache/kysely-write-cache.js\";\nimport type { WriteCacheConfig } from \"../../cache/write-cache-types.js\";\nimport { DEFAULT_DRIVE_CONTAINER_TYPES } from \"../../core/drive-container-types.js\";\nimport type { Database } from \"../../core/types.js\";\nimport { EventBus } from \"../../events/event-bus.js\";\nimport {\n ReactorEventTypes,\n type JobWriteReadyEvent,\n} from \"../../events/types.js\";\nimport { DocumentModelRegistry } from \"../../registry/implementation.js\";\nimport type { JobMeta } from \"../../shared/types.js\";\nimport type { SignatureVerificationHandler } from \"../../signer/types.js\";\nimport { KyselyKeyframeStore } from \"../../storage/kysely/keyframe-store.js\";\nimport { KyselyOperationStore } from \"../../storage/kysely/store.js\";\nimport type { Database as StorageDatabase } from \"../../storage/kysely/types.js\";\nimport { REACTOR_SCHEMA } from \"../../storage/migrations/migrator.js\";\nimport { KyselyExecutionScope } from \"../execution-scope.js\";\nimport { SimpleJobExecutor } from \"../simple-job-executor.js\";\nimport type { JobExecutorConfig } from \"../types.js\";\nimport type {\n FactorySpec,\n InitMessage,\n ModelManifestEntry,\n} from \"./protocol.js\";\n\n/**\n * In-worker capture of the JOB_WRITE_READY event emitted by the executor.\n * The worker forwards `operations` and `jobMeta` back to the parent; the\n * parent re-enriches `collectionMemberships` at emit time.\n */\nexport type WorkerWriteReadyCapture = {\n operations: OperationWithContext[];\n jobMeta: JobMeta;\n};\n\nexport type WorkerExecutorStack = {\n executor: SimpleJobExecutor;\n registry: DocumentModelRegistry;\n /**\n * Synchronously pops the most-recent JOB_WRITE_READY captured on this\n * worker's local event bus and clears it. Returns null if the executor\n * did not produce one for this job.\n */\n takeLastWriteReady(): WorkerWriteReadyCapture | null;\n};\n\nexport type BuildWorkerExecutorOptions = {\n init: InitMessage;\n database: Kysely<Database>;\n logger: ILogger;\n executorConfig?: JobExecutorConfig;\n driveContainerTypes?: ReadonlySet<string>;\n /**\n * Override the module loader used to materialize factory specs. Tests\n * can inject a deterministic resolver instead of touching the real\n * Node module loader.\n */\n loadFactory?: (spec: FactorySpec) => Promise<unknown>;\n};\n\nexport async function defaultLoadFactory(spec: FactorySpec): Promise<unknown> {\n const ref = spec.module;\n const specifier =\n \"filePath\" in ref\n ? new URL(`file://${ref.filePath}`).href\n : ref.packageName;\n const mod = (await import(specifier)) as Record<string, unknown>;\n const exported = mod[ref.exportName];\n if (typeof exported === \"function\") {\n return (exported as (args: unknown) => unknown)(spec.initArgs);\n }\n return exported;\n}\n\nasync function loadModelManifest(\n entries: ModelManifestEntry[],\n loadFactory: (spec: FactorySpec) => Promise<unknown>,\n registry: DocumentModelRegistry,\n logger: ILogger,\n): Promise<void> {\n for (const entry of entries) {\n let module: DocumentModelModule;\n try {\n module = (await loadFactory(entry.spec)) as DocumentModelModule;\n } catch (error) {\n logger.error(\n \"worker failed to load document model: @entry @error\",\n entry,\n error,\n );\n throw error;\n }\n const [result] = registry.registerModules(module);\n if (result.status === \"error\") {\n logger.error(\n \"worker failed to register document model: @entry @error\",\n entry,\n result.error,\n );\n throw result.error;\n }\n }\n}\n\n/**\n * Assembles the in-worker storage stack plus a {@link SimpleJobExecutor}\n * bound to a pre-built Kysely instance. The parent owns the wire protocol\n * and routing; the worker owns everything below `SimpleJobExecutor`.\n *\n * The local event bus exists only to satisfy the executor's contract: its\n * JOB_WRITE_READY emissions are captured here and shipped to the parent\n * via {@link WorkerExecutorStack.takeLastWriteReady}.\n */\nexport async function buildWorkerExecutor(\n options: BuildWorkerExecutorOptions,\n): Promise<WorkerExecutorStack> {\n const { init, database: baseDatabase, logger } = options;\n const driveContainerTypes =\n options.driveContainerTypes ?? DEFAULT_DRIVE_CONTAINER_TYPES;\n const loadFactory = options.loadFactory ?? defaultLoadFactory;\n\n const registry = new DocumentModelRegistry();\n await loadModelManifest(init.models, loadFactory, registry, logger);\n\n let signatureVerifier: SignatureVerificationHandler | undefined;\n if (init.signatureVerifier) {\n try {\n signatureVerifier = (await loadFactory(\n init.signatureVerifier,\n )) as SignatureVerificationHandler;\n } catch (error) {\n logger.error(\n \"worker failed to load signature verifier: @spec @error\",\n init.signatureVerifier,\n error,\n );\n throw error;\n }\n }\n\n const database = baseDatabase.withSchema(REACTOR_SCHEMA);\n const operationStore = new KyselyOperationStore(\n database as unknown as Kysely<StorageDatabase>,\n );\n const keyframeStore = new KyselyKeyframeStore(\n database as unknown as Kysely<StorageDatabase>,\n );\n\n const cacheConfig: WriteCacheConfig = {\n maxDocuments: 100,\n ringBufferSize: 10,\n keyframeInterval: 10,\n };\n const writeCache = new KyselyWriteCache(\n keyframeStore,\n operationStore,\n registry,\n cacheConfig,\n );\n await writeCache.startup();\n\n const operationIndex = new KyselyOperationIndex(\n database as unknown as Kysely<StorageDatabase>,\n );\n\n const documentMetaCache = new DocumentMetaCache(operationStore, {\n maxDocuments: 1000,\n });\n await documentMetaCache.startup();\n\n const collectionMembershipCache = new CollectionMembershipCache(\n operationIndex,\n );\n\n const executionScope = new KyselyExecutionScope(\n database as unknown as Kysely<StorageDatabase>,\n operationStore,\n operationIndex,\n keyframeStore,\n writeCache,\n documentMetaCache,\n collectionMembershipCache,\n );\n\n const eventBus = new EventBus();\n let lastWriteReady: WorkerWriteReadyCapture | null = null;\n eventBus.subscribe(\n ReactorEventTypes.JOB_WRITE_READY,\n (_t: number, event: JobWriteReadyEvent) => {\n lastWriteReady = {\n operations: event.operations,\n jobMeta: event.jobMeta,\n };\n },\n );\n\n const executorConfig = options.executorConfig ?? {};\n const executor = new SimpleJobExecutor(\n logger,\n registry,\n operationStore,\n eventBus,\n writeCache,\n operationIndex,\n documentMetaCache,\n collectionMembershipCache,\n driveContainerTypes,\n executorConfig,\n signatureVerifier,\n executionScope,\n );\n\n return {\n executor,\n registry,\n takeLastWriteReady(): WorkerWriteReadyCapture | null {\n const captured = lastWriteReady;\n lastWriteReady = null;\n return captured;\n },\n };\n}\n"],"mappings":";;;AAqEA,eAAsB,mBAAmB,MAAqC;CAC5E,MAAM,MAAM,KAAK;CAMjB,MAAM,YADO,OAHX,cAAc,MAAA,OACV,IAAI,IAAI,UAAU,IAAI,WAAW,CAAC,QAAA,OAClC,IAAI,eAEW,IAAI;AACzB,KAAI,OAAO,aAAa,WACtB,QAAQ,SAAwC,KAAK,SAAS;AAEhE,QAAO;;AAGT,eAAe,kBACb,SACA,aACA,UACA,QACe;AACf,MAAK,MAAM,SAAS,SAAS;EAC3B,IAAI;AACJ,MAAI;AACF,YAAU,MAAM,YAAY,MAAM,KAAK;WAChC,OAAO;AACd,UAAO,MACL,uDACA,OACA,MACD;AACD,SAAM;;EAER,MAAM,CAAC,UAAU,SAAS,gBAAgB,OAAO;AACjD,MAAI,OAAO,WAAW,SAAS;AAC7B,UAAO,MACL,2DACA,OACA,OAAO,MACR;AACD,SAAM,OAAO;;;;;;;;;;;;;AAcnB,eAAsB,oBACpB,SAC8B;CAC9B,MAAM,EAAE,MAAM,UAAU,cAAc,WAAW;CACjD,MAAM,sBACJ,QAAQ,uBAAuB;CACjC,MAAM,cAAc,QAAQ,eAAe;CAE3C,MAAM,WAAW,IAAI,uBAAuB;AAC5C,OAAM,kBAAkB,KAAK,QAAQ,aAAa,UAAU,OAAO;CAEnE,IAAI;AACJ,KAAI,KAAK,kBACP,KAAI;AACF,sBAAqB,MAAM,YACzB,KAAK,kBACN;UACM,OAAO;AACd,SAAO,MACL,0DACA,KAAK,mBACL,MACD;AACD,QAAM;;CAIV,MAAM,WAAW,aAAa,WAAW,eAAe;CACxD,MAAM,iBAAiB,IAAI,qBACzB,SACD;CACD,MAAM,gBAAgB,IAAI,oBACxB,SACD;CAOD,MAAM,aAAa,IAAI,iBACrB,eACA,gBACA,UARoC;EACpC,cAAc;EACd,gBAAgB;EAChB,kBAAkB;EACnB,CAMA;AACD,OAAM,WAAW,SAAS;CAE1B,MAAM,iBAAiB,IAAI,qBACzB,SACD;CAED,MAAM,oBAAoB,IAAI,kBAAkB,gBAAgB,EAC9D,cAAc,KACf,CAAC;AACF,OAAM,kBAAkB,SAAS;CAEjC,MAAM,4BAA4B,IAAI,0BACpC,eACD;CAED,MAAM,iBAAiB,IAAI,qBACzB,UACA,gBACA,gBACA,eACA,YACA,mBACA,0BACD;CAED,MAAM,WAAW,IAAI,UAAU;CAC/B,IAAI,iBAAiD;AACrD,UAAS,UACP,kBAAkB,kBACjB,IAAY,UAA8B;AACzC,mBAAiB;GACf,YAAY,MAAM;GAClB,SAAS,MAAM;GAChB;GAEJ;AAkBD,QAAO;EACL,UAhBe,IAAI,kBACnB,QACA,UACA,gBACA,UACA,YACA,gBACA,mBACA,2BACA,qBAVqB,QAAQ,kBAAkB,EAAE,EAYjD,mBACA,eACD;EAIC;EACA,qBAAqD;GACnD,MAAM,WAAW;AACjB,oBAAiB;AACjB,UAAO;;EAEV"}
|
package/dist/entry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { o as instrumentPgPool } from "./drive-container-types-DpJp2AmE.js";
|
|
2
2
|
import { n as errorToInfo, t as createForwardingLogger } from "./forwarding-logger-BBkMSxuJ.js";
|
|
3
|
-
import { n as defaultLoadFactory, t as buildWorkerExecutor } from "./build-worker-executor
|
|
3
|
+
import { n as defaultLoadFactory, t as buildWorkerExecutor } from "./build-worker-executor--nhFRF47.js";
|
|
4
4
|
import { ConsoleLogger } from "document-model";
|
|
5
5
|
import { isMainThread, parentPort } from "node:worker_threads";
|
|
6
6
|
//#region src/executor/worker/run-worker.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -2242,8 +2242,8 @@ type InitMessage = {
|
|
|
2242
2242
|
correlationId: string;
|
|
2243
2243
|
workerId: string;
|
|
2244
2244
|
poolConfig: WorkerPoolConfig;
|
|
2245
|
-
db: DbConfig;
|
|
2246
|
-
signatureVerifier
|
|
2245
|
+
db: DbConfig; /** Omitted = the worker performs no executor-side signature verification. */
|
|
2246
|
+
signatureVerifier?: SignatureVerifierSpec;
|
|
2247
2247
|
models: ModelManifestEntry[];
|
|
2248
2248
|
};
|
|
2249
2249
|
/**
|
|
@@ -2749,6 +2749,25 @@ interface DocumentViewDatabase {
|
|
|
2749
2749
|
}
|
|
2750
2750
|
type InsertableDocumentSnapshot = Insertable<DocumentSnapshotTable>;
|
|
2751
2751
|
//#endregion
|
|
2752
|
+
//#region src/core/model-sources.d.ts
|
|
2753
|
+
/** An importable file holding one or more document-model exports. */
|
|
2754
|
+
type FileModelSource = {
|
|
2755
|
+
filePath: string;
|
|
2756
|
+
exportName?: string;
|
|
2757
|
+
};
|
|
2758
|
+
/** An importable package specifier holding one or more document-model exports. */
|
|
2759
|
+
type PackageModelSource = {
|
|
2760
|
+
packageName: string;
|
|
2761
|
+
subpath?: string;
|
|
2762
|
+
exportName?: string;
|
|
2763
|
+
};
|
|
2764
|
+
/**
|
|
2765
|
+
* A source of document models: a live module, an importable file, or an
|
|
2766
|
+
* importable package. File and package sources can cross a worker-thread
|
|
2767
|
+
* boundary (workers re-import them); a live module cannot.
|
|
2768
|
+
*/
|
|
2769
|
+
type DocumentModelSource = DocumentModelModule<any> | FileModelSource | PackageModelSource;
|
|
2770
|
+
//#endregion
|
|
2752
2771
|
//#region src/registry/interfaces.d.ts
|
|
2753
2772
|
type RegistrationResult<T> = {
|
|
2754
2773
|
status: "success";
|
|
@@ -2759,18 +2778,18 @@ type RegistrationResult<T> = {
|
|
|
2759
2778
|
error: Error;
|
|
2760
2779
|
};
|
|
2761
2780
|
/**
|
|
2762
|
-
* Loader that
|
|
2763
|
-
*
|
|
2764
|
-
* until the required model is available in the registry.
|
|
2781
|
+
* Loader that asynchronously resolves a document type to a
|
|
2782
|
+
* {@link DocumentModelSource}. Used by the queue to gate CREATE_DOCUMENT
|
|
2783
|
+
* jobs until the required model is available in the registry.
|
|
2765
2784
|
*
|
|
2766
|
-
*
|
|
2767
|
-
*
|
|
2768
|
-
*
|
|
2769
|
-
*
|
|
2785
|
+
* Return an importable source ({ filePath } or { packageName }) whenever
|
|
2786
|
+
* possible: the resolver registers the resolved models on the host registry
|
|
2787
|
+
* and broadcasts importable sources to executor workers. A live
|
|
2788
|
+
* DocumentModelModule is also valid but host-only — it cannot cross a
|
|
2789
|
+
* worker-thread boundary, so worker pools will not receive it.
|
|
2770
2790
|
*/
|
|
2771
2791
|
interface IDocumentModelLoader {
|
|
2772
|
-
load(documentType: string): Promise<
|
|
2773
|
-
resolveSpec?(documentType: string): Promise<ModelManifestEntry | null>;
|
|
2792
|
+
load(documentType: string): Promise<DocumentModelSource>;
|
|
2774
2793
|
}
|
|
2775
2794
|
/**
|
|
2776
2795
|
* Registry for managing document model modules.
|
|
@@ -3841,7 +3860,6 @@ declare class DocumentModelResolver implements IDocumentModelResolver {
|
|
|
3841
3860
|
ensureModelLoaded(documentType: string): Promise<void>;
|
|
3842
3861
|
private loadRegisterAndBroadcast;
|
|
3843
3862
|
private notifyPeersModelLoaded;
|
|
3844
|
-
private broadcastIfPossible;
|
|
3845
3863
|
}
|
|
3846
3864
|
/**
|
|
3847
3865
|
* No-op resolver used when no document model loader is configured.
|
|
@@ -4153,16 +4171,28 @@ interface ReadModelFactoryDeps {
|
|
|
4153
4171
|
* dependencies once they are available. Awaited during `buildModule()`.
|
|
4154
4172
|
*/
|
|
4155
4173
|
type ReadModelFactory = (deps: ReadModelFactoryDeps) => IReadModel | Promise<IReadModel>;
|
|
4174
|
+
type WorkerPoolBase = {
|
|
4175
|
+
/** Number of worker threads to spawn; also the sticky-routing modulus. */numWorkers: number;
|
|
4176
|
+
/**
|
|
4177
|
+
* Factory spec the default transport's workers import to instantiate
|
|
4178
|
+
* their signature verifier. Omitted = no executor-side verification,
|
|
4179
|
+
* parity with the in-process executor's default.
|
|
4180
|
+
*/
|
|
4181
|
+
verifier?: SignatureVerifierSpec;
|
|
4182
|
+
};
|
|
4156
4183
|
/**
|
|
4157
|
-
*
|
|
4158
|
-
*
|
|
4184
|
+
* Executor worker-pool configuration. Either `db` (default thread
|
|
4185
|
+
* transport; each worker opens its own Postgres pool) or a custom
|
|
4186
|
+
* `factory` transport is required by construction — an enabled pool
|
|
4187
|
+
* without connection info is unrepresentable.
|
|
4159
4188
|
*/
|
|
4160
|
-
type
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
} | {
|
|
4164
|
-
|
|
4165
|
-
|
|
4189
|
+
type WorkerPoolOptions = (WorkerPoolBase & {
|
|
4190
|
+
db: DbConfig;
|
|
4191
|
+
factory?: WorkerFactory;
|
|
4192
|
+
}) | (WorkerPoolBase & {
|
|
4193
|
+
db?: DbConfig;
|
|
4194
|
+
factory: WorkerFactory;
|
|
4195
|
+
});
|
|
4166
4196
|
/**
|
|
4167
4197
|
* Caller-facing config for {@link ReactorBuilder.withProjectionShards}.
|
|
4168
4198
|
* When set, the builder replaces the in-process
|
|
@@ -4177,6 +4207,12 @@ type ProjectionShardBuilderConfig = {
|
|
|
4177
4207
|
shardCount: number;
|
|
4178
4208
|
preReadyKinds: BuiltInReadModelKind[];
|
|
4179
4209
|
postReadyKinds: BuiltInReadModelKind[];
|
|
4210
|
+
/**
|
|
4211
|
+
* Connection info for the projection workers' own pools. Falls back to
|
|
4212
|
+
* the executor worker pool's `db` when {@link ReactorBuilder.withWorkerPool}
|
|
4213
|
+
* is configured with one.
|
|
4214
|
+
*/
|
|
4215
|
+
db?: DbConfig;
|
|
4180
4216
|
poolSize?: number;
|
|
4181
4217
|
initTimeoutMs?: number;
|
|
4182
4218
|
shutdownGraceMs?: number;
|
|
@@ -4185,7 +4221,7 @@ type ProjectionShardBuilderConfig = {
|
|
|
4185
4221
|
};
|
|
4186
4222
|
declare class ReactorBuilder {
|
|
4187
4223
|
private logger?;
|
|
4188
|
-
private
|
|
4224
|
+
private documentModelSources;
|
|
4189
4225
|
private upgradeManifests;
|
|
4190
4226
|
private features;
|
|
4191
4227
|
private readModels;
|
|
@@ -4206,17 +4242,20 @@ declare class ReactorBuilder {
|
|
|
4206
4242
|
private documentModelLoader?;
|
|
4207
4243
|
private shutdownHooks;
|
|
4208
4244
|
private driveContainerTypes;
|
|
4209
|
-
private
|
|
4210
|
-
private workerPoolConfig?;
|
|
4245
|
+
private workerPool?;
|
|
4211
4246
|
private resolvedModelManifest?;
|
|
4212
|
-
private workerDbConfig?;
|
|
4213
|
-
private workerSignatureVerifierSpec?;
|
|
4214
|
-
private workerFactory?;
|
|
4215
4247
|
private projectionShardConfig?;
|
|
4216
4248
|
private projectionWorkerFactory?;
|
|
4217
4249
|
private instrumentedPools;
|
|
4218
4250
|
withLogger(logger: ILogger): this;
|
|
4219
|
-
|
|
4251
|
+
/**
|
|
4252
|
+
* Register document-model sources: live modules, importable files, or
|
|
4253
|
+
* importable packages. Appends across calls. At `buildModule()` every
|
|
4254
|
+
* source is resolved host-side and registered on the registry; file and
|
|
4255
|
+
* package sources additionally form the worker manifest when the worker
|
|
4256
|
+
* pool is enabled (live modules cannot cross a thread boundary).
|
|
4257
|
+
*/
|
|
4258
|
+
withDocumentModelSources(sources: DocumentModelSource[]): this;
|
|
4220
4259
|
withUpgradeManifests(manifests: UpgradeManifest<readonly number[]>[]): this;
|
|
4221
4260
|
withFeatures(features: ReactorFeatures): this;
|
|
4222
4261
|
withReadModel(readModel: IReadModel): this;
|
|
@@ -4260,43 +4299,27 @@ declare class ReactorBuilder {
|
|
|
4260
4299
|
* shutdown chain.
|
|
4261
4300
|
*/
|
|
4262
4301
|
withShutdownHook(hook: () => Promise<void>): this;
|
|
4263
|
-
withDocumentModelSpecs(specs: DocumentModelSpecInput[]): this;
|
|
4264
|
-
/**
|
|
4265
|
-
* Stores the worker-pool configuration. When `config.enabled === true` the
|
|
4266
|
-
* builder constructs a {@link WorkerPoolJobExecutorManager} in place of the
|
|
4267
|
-
* in-process {@link SimpleJobExecutorManager}.
|
|
4268
|
-
*/
|
|
4269
|
-
withWorkerPool(config: WorkerPoolConfig): this;
|
|
4270
|
-
/**
|
|
4271
|
-
* Postgres connection info forwarded to each worker so it can open its own
|
|
4272
|
-
* pool. Required when `workerPool.enabled === true` unless a custom
|
|
4273
|
-
* `withWorkerFactory` or `withExecutor` is provided.
|
|
4274
|
-
*/
|
|
4275
|
-
withWorkerDbConfig(db: DbConfig): this;
|
|
4276
4302
|
/**
|
|
4277
|
-
*
|
|
4278
|
-
*
|
|
4279
|
-
* `
|
|
4303
|
+
* Enable the executor worker pool: N `node:worker_threads` workers with
|
|
4304
|
+
* sticky per-document routing, replacing the in-process executor. Calling
|
|
4305
|
+
* this enables the pool — there is no `enabled` flag. Provide `db`
|
|
4306
|
+
* (each worker opens its own Postgres pool; the parent database is built
|
|
4307
|
+
* from it too unless {@link withKysely} is set) or a custom `factory`
|
|
4308
|
+
* transport. `verifier` is imported by the default transport's workers;
|
|
4309
|
+
* omitted = no executor-side signature verification.
|
|
4280
4310
|
*/
|
|
4281
|
-
|
|
4282
|
-
/**
|
|
4283
|
-
* Inject a custom {@link WorkerFactory}. When set, the builder skips
|
|
4284
|
-
* default thread-transport wiring and hands the factory directly to the
|
|
4285
|
-
* pool manager. Use this in tests or to plug in a different transport
|
|
4286
|
-
* (e.g. a child-process adapter).
|
|
4287
|
-
*/
|
|
4288
|
-
withWorkerFactory(factory: WorkerFactory): this;
|
|
4311
|
+
withWorkerPool(options: WorkerPoolOptions): this;
|
|
4289
4312
|
/**
|
|
4290
4313
|
* Configure N sharded projection workers. When set, the builder replaces
|
|
4291
4314
|
* the default in-process {@link ReadModelCoordinator} with a
|
|
4292
|
-
* {@link ProjectionShardManager}.
|
|
4293
|
-
* {@link withWorkerDbConfig} is reused for the projection workers'
|
|
4294
|
-
* connection info; only the `poolSize` is overridden by
|
|
4295
|
-
* {@link ProjectionShardBuilderConfig.poolSize}.
|
|
4315
|
+
* {@link ProjectionShardManager}.
|
|
4296
4316
|
*
|
|
4297
|
-
*
|
|
4298
|
-
*
|
|
4299
|
-
*
|
|
4317
|
+
* Projection workers open their own Postgres pools from `config.db`,
|
|
4318
|
+
* falling back to the executor worker pool's `db` when
|
|
4319
|
+
* {@link withWorkerPool} is configured with one; only the `poolSize` is
|
|
4320
|
+
* overridden by {@link ProjectionShardBuilderConfig.poolSize}. The same
|
|
4321
|
+
* model manifest resolved from {@link withDocumentModelSources} is
|
|
4322
|
+
* forwarded.
|
|
4300
4323
|
*/
|
|
4301
4324
|
withProjectionShards(config: ProjectionShardBuilderConfig): this;
|
|
4302
4325
|
/**
|
|
@@ -4308,6 +4331,14 @@ declare class ReactorBuilder {
|
|
|
4308
4331
|
getResolvedModelManifest(): ModelManifestEntry[] | undefined;
|
|
4309
4332
|
build(): Promise<IReactor>;
|
|
4310
4333
|
buildModule(): Promise<InProcessReactorModule>;
|
|
4334
|
+
/**
|
|
4335
|
+
* The single Postgres config for the parent, executor workers, and
|
|
4336
|
+
* projection shards. They must share one physical database (the parent
|
|
4337
|
+
* writes operations; workers and shards read them), so divergent
|
|
4338
|
+
* worker/shard targets throw. `withKysely` overrides the parent and is not
|
|
4339
|
+
* validated against a worker/shard `db`.
|
|
4340
|
+
*/
|
|
4341
|
+
private resolveReactorDbConfig;
|
|
4311
4342
|
/**
|
|
4312
4343
|
* Constructs a {@link ProjectionShardManager} bound to the host event
|
|
4313
4344
|
* bus. Builds the default thread-transport factory unless one was
|
|
@@ -4318,9 +4349,9 @@ declare class ReactorBuilder {
|
|
|
4318
4349
|
private createProjectionShardManager;
|
|
4319
4350
|
private createDefaultProjectionWorkerFactory;
|
|
4320
4351
|
/**
|
|
4321
|
-
* Default {@link WorkerFactory} used when
|
|
4322
|
-
*
|
|
4323
|
-
*
|
|
4352
|
+
* Default {@link WorkerFactory} used when the pool options carry no
|
|
4353
|
+
* custom `factory`. Each worker spawns a real `node:worker_threads`
|
|
4354
|
+
* Worker pointing at the compiled `worker/entry.js`.
|
|
4324
4355
|
*/
|
|
4325
4356
|
private createDefaultWorkerFactory;
|
|
4326
4357
|
/**
|
|
@@ -5676,5 +5707,5 @@ declare class ProcessorManager extends BaseReadModel implements IProcessorManage
|
|
|
5676
5707
|
private deleteProcessorCursors;
|
|
5677
5708
|
}
|
|
5678
5709
|
//#endregion
|
|
5679
|
-
export { type AbortMessage, type AtomicTxn, type AttachmentHash, type AttachmentRef, BaseReadModel, type BatchExecutionRequest, type BatchExecutionResult, type BatchLoadRequest, type BatchLoadResult, type BuiltInReadModelKind, type CachedSnapshot, type ChannelConfig, ChannelError, ChannelErrorSource, type ChannelHealth, type ChannelMeta, ChannelScheme, type ConnectionState, type ConnectionStateChangeCallback, type ConnectionStateChangedEvent, type ConnectionStateSnapshot, type ConsistencyCoordinate, type ConsistencyKey, type ConsistencyToken, ConsistencyTracker, DEFAULT_DRIVE_CONTAINER_TYPES, DRIVE_AUTH_ERROR_MESSAGES, type Database, type DbConfig, type DeadLetterAddedEvent, DefaultSubscriptionErrorHandler, type DocumentChangeEvent, DocumentChangeType, type DocumentGraphEdge, type DocumentIndexerDatabase, DocumentIntegrityService, DocumentModelRegistry, DocumentModelResolver, type
|
|
5710
|
+
export { type AbortMessage, type AtomicTxn, type AttachmentHash, type AttachmentRef, BaseReadModel, type BatchExecutionRequest, type BatchExecutionResult, type BatchLoadRequest, type BatchLoadResult, type BuiltInReadModelKind, type CachedSnapshot, type ChannelConfig, ChannelError, ChannelErrorSource, type ChannelHealth, type ChannelMeta, ChannelScheme, type ConnectionState, type ConnectionStateChangeCallback, type ConnectionStateChangedEvent, type ConnectionStateSnapshot, type ConsistencyCoordinate, type ConsistencyKey, type ConsistencyToken, ConsistencyTracker, DEFAULT_DRIVE_CONTAINER_TYPES, DRIVE_AUTH_ERROR_MESSAGES, type Database, type DbConfig, type DeadLetterAddedEvent, DefaultSubscriptionErrorHandler, type DocumentChangeEvent, DocumentChangeType, type DocumentGraphEdge, type DocumentIndexerDatabase, DocumentIntegrityService, DocumentModelRegistry, DocumentModelResolver, type DocumentModelSource, type DocumentModelSpec, type DocumentRelationship, type DocumentRevisions, type DocumentStreamKey, type DocumentViewDatabase, DriveClient, DriveCollectionId, DuplicateManifestError, DuplicateModuleError, DuplicateOperationError, EventBus, EventBusAggregateError, type ExecuteMessage, type ExecutionJobPlan, type ExecutorStartedEvent, type ExecutorStoppedEvent, type FactorySpec, type FileModelSource, type GqlChannelConfig, GqlRequestChannel, GqlRequestChannelFactory, GqlResponseChannel, GqlResponseChannelFactory, type HeartbeatMessage, type IChannel, type IChannelFactory, type IConsistencyTracker, type IDocumentGraph, type IDocumentIndexer, type IDocumentIntegrityService, type IDocumentModelLoader, type IDocumentModelRegistry, type IDocumentModelResolver, type IDocumentView, type IDriveClient, type IEventBus, type IJobAwaiter, type IJobExecutor, type IJobExecutorManager, type IJobTracker, type IKeyframeStore, type IMailbox, type IOperationIndex, type IOperationStore, type IPollTimer, type IProcessor, type IProcessorHostModule, type IProcessorManager, type IProjectionTransport, type IQueue, type IReactor, type IReactorClient, type IReactorSubscriptionManager, type IReadModel, type IReadModelCoordinator, type IRelationalDb, type ISubscriptionErrorHandler, type ISyncCursorStorage, type ISyncManager, type ISyncRemoteStorage, type ISyncStatusTracker, type IWriteCache, SimpleJobExecutor as InMemoryJobExecutor, SimpleJobExecutor, InMemoryJobTracker, InMemoryQueue, type InProcessReactorClientModule, type InProcessReactorModule, type InProcessSyncModule, type InitMessage, type InsertableDocumentSnapshot, IntervalPollTimer, InvalidModuleError, type Job, type JobAvailableEvent, JobAwaiter, type JobCompletedEvent, type JobExecutorConfig, JobExecutorEventTypes, type JobExecutorFactory, type JobFailedEvent, type JobInfo, type JobPendingEvent, type JobReadReadyEvent, type JobResult, type JobRunningEvent, type JobStartedEvent, JobStatus, type JobWriteReadyEvent, type JobWriteReadyPayload, type JwtHandler, type KeyframeSnapshot, type KeyframeValidationIssue, KyselyDocumentIndexer, KyselyDocumentView, KyselyKeyframeStore, KyselyOperationStore, KyselySyncCursorStorage, KyselySyncRemoteStorage, KyselyWriteCache, type LoadJobPlan, type LoadModelMessage, type LogMessage, Mailbox, type MetricsMessage, type ModelLoadFailedMessage, type ModelLoadedEvent, type ModelLoadedMessage, type ModelManifestEntry, ModuleNotFoundError, type ModuleRef, NullDocumentModelResolver, type OperationBatch, type OperationContext, type OperationFilter, type OperationIndexEntry, type OperationTable, type OperationWithContext, OptimisticLockError, type PackageModelSource, type PagedResults, type PagingOptions, type ParentMessage, type ParsedDriveUrl, type ParsedPaging, PollBehavior, PollingChannelError, type PoolInstrumentation, type PoolStats, type ProcessorApp, type ProcessorFactory, type ProcessorFactoryBuilder, type ProcessorFilter, ProcessorManager, type ProcessorRecord, type ProcessorStatus, type ProjectionShardBuilderConfig, type ProjectionShardManagerConfig, type ProjectionWorkerFactory, PropagationMode, QueueEventTypes, REACTOR_SCHEMA, Reactor, ReactorBuilder, ReactorClient, ReactorClientBuilder, type ReactorClientModule, ReactorEventTypes, type ReactorFeatures, type JobFailedEvent$1 as ReactorJobFailedEvent, type ReactorModule, ReactorSubscriptionManager, type ReadModelBatchCompletedEvent, ReadModelCoordinator, type ReadModelFactory, type ReadModelFactoryDeps, type ReadModelIndexedEvent, type ReadModelIndexingStage, type ReadModelStage, type ReadyMessage, type RebuildResult, RelationalDbProcessor, RelationshipChangeType, type Remote, type RemoteCursor, type RemoteFilter, type RemoteMeta, type RemoteOptions, type RemoteRecord, type RemoteStatus, type ResultMessage, RevisionMismatchError, type SanitizedArg, type SearchFilter, type ShutdownMessage, type ShutdownStatus, type SignatureVerificationHandler, type SignatureVerifierSpec, type SignerConfig, SimpleJobExecutorManager, type SnapshotValidationIssue, type Database$1 as StorageDatabase, type SubscriptionErrorContext, SyncBuilder, type SyncEnvelope, type SyncEnvelopeType, SyncEventTypes, type SyncFailedEvent, type SyncModule, SyncOperation, SyncOperationAggregateError, type SyncOperationErrorType, SyncOperationStatus, type SyncPendingEvent, SyncStatus, type SyncStatusChangeCallback, SyncStatusTracker, type SyncSucceededEvent, type TrackedProcessor, type Unsubscribe, type ValidationResult, type ViewFilter, type ErrorInfo as WorkerErrorInfo, type WorkerMessage, type WorkerPoolConfig, type WorkerPoolOptions, type WriteCacheConfig, addRelationshipAction, batchOperationsByDocument, consolidateSyncOperations, createDocumentAction, createForwardingLogger, createMutableShutdownStatus, createRelationalDb, deleteDocumentAction, documentActions, driveIdFromUrl, envelopesToSyncOperations, errorToInfo, getMigrationStatus, instrumentPgPool, isDriveAuthError, makeConsistencyKey, parseDriveUrl, parsePagingOptions, removeRelationshipAction, runMigrations, sanitizeArg, trimMailboxFromAckOrdinal, updateRelationshipAction, upgradeDocumentAction, workerEntryPath };
|
|
5680
5711
|
//# sourceMappingURL=index.d.ts.map
|