@514labs/moose-lib 0.6.267-ci-2-g3cd14684 → 0.6.267-ci-3-g2d546d7e
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/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/index.js +90 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -27
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +135 -43
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +135 -43
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +1 -1
package/dist/moose-runner.js
CHANGED
|
@@ -975,8 +975,15 @@ var runApis = async (config) => {
|
|
|
975
975
|
const apisCluster = new Cluster({
|
|
976
976
|
maxWorkerCount: (config.workerCount ?? 0) > 0 ? config.workerCount : void 0,
|
|
977
977
|
workerStart: async () => {
|
|
978
|
+
const workerInfo = `[Worker ${process.pid}]`;
|
|
979
|
+
const startTime = Date.now();
|
|
980
|
+
console.log(`${workerInfo} workerStart: beginning initialization`);
|
|
978
981
|
let temporalClient;
|
|
979
982
|
if (config.temporalConfig) {
|
|
983
|
+
const temporalStart = Date.now();
|
|
984
|
+
console.log(
|
|
985
|
+
`${workerInfo} workerStart: initializing Temporal client...`
|
|
986
|
+
);
|
|
980
987
|
temporalClient = await getTemporalClient(
|
|
981
988
|
config.temporalConfig.url,
|
|
982
989
|
config.temporalConfig.namespace,
|
|
@@ -984,29 +991,51 @@ var runApis = async (config) => {
|
|
|
984
991
|
config.temporalConfig.clientKey,
|
|
985
992
|
config.temporalConfig.apiKey
|
|
986
993
|
);
|
|
994
|
+
console.log(
|
|
995
|
+
`${workerInfo} workerStart: Temporal client initialized in ${Date.now() - temporalStart}ms`
|
|
996
|
+
);
|
|
987
997
|
}
|
|
998
|
+
const clickhouseStart = Date.now();
|
|
999
|
+
console.log(
|
|
1000
|
+
`${workerInfo} workerStart: initializing ClickHouse client...`
|
|
1001
|
+
);
|
|
988
1002
|
const clickhouseClient = getClickhouseClient(
|
|
989
1003
|
toClientConfig(config.clickhouseConfig)
|
|
990
1004
|
);
|
|
1005
|
+
console.log(
|
|
1006
|
+
`${workerInfo} workerStart: ClickHouse client initialized in ${Date.now() - clickhouseStart}ms`
|
|
1007
|
+
);
|
|
991
1008
|
let publicKey;
|
|
992
1009
|
if (config.jwtConfig?.secret) {
|
|
993
|
-
|
|
1010
|
+
const jwtStart = Date.now();
|
|
1011
|
+
console.log(`${workerInfo} workerStart: importing JWT public key...`);
|
|
994
1012
|
publicKey = await jose.importSPKI(config.jwtConfig.secret, "RS256");
|
|
1013
|
+
console.log(
|
|
1014
|
+
`${workerInfo} workerStart: JWT key imported in ${Date.now() - jwtStart}ms`
|
|
1015
|
+
);
|
|
995
1016
|
}
|
|
996
|
-
const
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1017
|
+
const routerStart = Date.now();
|
|
1018
|
+
console.log(`${workerInfo} workerStart: creating main router...`);
|
|
1019
|
+
const router = await createMainRouter(
|
|
1020
|
+
publicKey,
|
|
1021
|
+
clickhouseClient,
|
|
1022
|
+
temporalClient,
|
|
1023
|
+
config.apisDir,
|
|
1024
|
+
config.enforceAuth,
|
|
1025
|
+
config.isDmv2,
|
|
1026
|
+
config.jwtConfig
|
|
1027
|
+
);
|
|
1028
|
+
console.log(
|
|
1029
|
+
`${workerInfo} workerStart: main router created in ${Date.now() - routerStart}ms`
|
|
1006
1030
|
);
|
|
1031
|
+
const serverStart = Date.now();
|
|
1032
|
+
console.log(`${workerInfo} workerStart: creating HTTP server...`);
|
|
1033
|
+
const server = import_http2.default.createServer(router);
|
|
1007
1034
|
const port = config.proxyPort !== void 0 ? config.proxyPort : 4001;
|
|
1008
1035
|
server.listen(port, "localhost", () => {
|
|
1009
|
-
console.log(
|
|
1036
|
+
console.log(
|
|
1037
|
+
`${workerInfo} Server running on port ${port} (total startup: ${Date.now() - startTime}ms)`
|
|
1038
|
+
);
|
|
1010
1039
|
});
|
|
1011
1040
|
return server;
|
|
1012
1041
|
},
|
|
@@ -1627,43 +1656,106 @@ if (getMooseInternal() === void 0) {
|
|
|
1627
1656
|
globalThis.moose_internal = moose_internal;
|
|
1628
1657
|
}
|
|
1629
1658
|
var dumpMooseInternal = async () => {
|
|
1630
|
-
loadIndex();
|
|
1659
|
+
await loadIndex();
|
|
1631
1660
|
console.log(
|
|
1632
1661
|
"___MOOSE_STUFF___start",
|
|
1633
1662
|
JSON.stringify(toInfraMap(getMooseInternal())),
|
|
1634
1663
|
"end___MOOSE_STUFF___"
|
|
1635
1664
|
);
|
|
1636
1665
|
};
|
|
1637
|
-
var
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
try {
|
|
1653
|
-
require(`${import_process.default.cwd()}/${getSourceDir()}/index.ts`);
|
|
1654
|
-
} catch (error) {
|
|
1655
|
-
let hint;
|
|
1656
|
-
const details = error instanceof Error ? error.message : String(error);
|
|
1657
|
-
if (details.includes("ERR_REQUIRE_ESM") || details.includes("ES Module")) {
|
|
1658
|
-
hint = "The file or its dependencies are ESM-only. Switch to packages that dual-support CJS & ESM, or upgrade to Node 22.12+. If you must use Node 20, you may try Node 20.19\n\n";
|
|
1659
|
-
}
|
|
1660
|
-
const errorMsg = `${hint ?? ""}${details}`;
|
|
1661
|
-
const cause = error instanceof Error ? error : void 0;
|
|
1662
|
-
throw new Error(errorMsg, { cause });
|
|
1666
|
+
var indexLoadState = "unloaded";
|
|
1667
|
+
var indexLoadPromise = null;
|
|
1668
|
+
var loadIndex = async () => {
|
|
1669
|
+
const workerInfo = `[Worker ${import_process.default.pid}]`;
|
|
1670
|
+
if (indexLoadState === "loaded") {
|
|
1671
|
+
console.log(
|
|
1672
|
+
`${workerInfo} loadIndex: already loaded, returning immediately`
|
|
1673
|
+
);
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
if (indexLoadState === "loading" && indexLoadPromise) {
|
|
1677
|
+
console.log(
|
|
1678
|
+
`${workerInfo} loadIndex: already loading, waiting for completion`
|
|
1679
|
+
);
|
|
1680
|
+
return indexLoadPromise;
|
|
1663
1681
|
}
|
|
1682
|
+
console.log(`${workerInfo} loadIndex: starting load process`);
|
|
1683
|
+
const startTime = Date.now();
|
|
1684
|
+
const delay = Math.random() * 500;
|
|
1685
|
+
console.log(
|
|
1686
|
+
`${workerInfo} loadIndex: waiting ${delay.toFixed(0)}ms to stagger load`
|
|
1687
|
+
);
|
|
1688
|
+
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
1689
|
+
if (indexLoadState === "loading" && indexLoadPromise) {
|
|
1690
|
+
console.log(
|
|
1691
|
+
`${workerInfo} loadIndex: another worker started loading during delay, waiting`
|
|
1692
|
+
);
|
|
1693
|
+
return indexLoadPromise;
|
|
1694
|
+
}
|
|
1695
|
+
if (indexLoadState === "loaded") {
|
|
1696
|
+
console.log(
|
|
1697
|
+
`${workerInfo} loadIndex: loaded by another worker during delay`
|
|
1698
|
+
);
|
|
1699
|
+
return;
|
|
1700
|
+
}
|
|
1701
|
+
indexLoadState = "loading";
|
|
1702
|
+
indexLoadPromise = (async () => {
|
|
1703
|
+
try {
|
|
1704
|
+
console.log(`${workerInfo} loadIndex: clearing registry...`);
|
|
1705
|
+
const clearStart = Date.now();
|
|
1706
|
+
const registry = getMooseInternal();
|
|
1707
|
+
registry.tables.clear();
|
|
1708
|
+
registry.streams.clear();
|
|
1709
|
+
registry.ingestApis.clear();
|
|
1710
|
+
registry.apis.clear();
|
|
1711
|
+
registry.sqlResources.clear();
|
|
1712
|
+
registry.workflows.clear();
|
|
1713
|
+
registry.webApps.clear();
|
|
1714
|
+
console.log(
|
|
1715
|
+
`${workerInfo} loadIndex: registry cleared in ${Date.now() - clearStart}ms`
|
|
1716
|
+
);
|
|
1717
|
+
console.log(`${workerInfo} loadIndex: clearing require cache...`);
|
|
1718
|
+
const cacheStart = Date.now();
|
|
1719
|
+
const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
|
|
1720
|
+
Object.keys(require.cache).forEach((key) => {
|
|
1721
|
+
if (key.startsWith(appDir)) {
|
|
1722
|
+
delete require.cache[key];
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
console.log(
|
|
1726
|
+
`${workerInfo} loadIndex: require cache cleared in ${Date.now() - cacheStart}ms`
|
|
1727
|
+
);
|
|
1728
|
+
console.log(`${workerInfo} loadIndex: requiring index.ts...`);
|
|
1729
|
+
const requireStart = Date.now();
|
|
1730
|
+
require(`${import_process.default.cwd()}/${getSourceDir()}/index.ts`);
|
|
1731
|
+
console.log(
|
|
1732
|
+
`${workerInfo} loadIndex: require completed in ${Date.now() - requireStart}ms`
|
|
1733
|
+
);
|
|
1734
|
+
indexLoadState = "loaded";
|
|
1735
|
+
console.log(
|
|
1736
|
+
`${workerInfo} loadIndex: total load time ${Date.now() - startTime}ms`
|
|
1737
|
+
);
|
|
1738
|
+
} catch (error) {
|
|
1739
|
+
console.error(
|
|
1740
|
+
`${workerInfo} loadIndex: FAILED after ${Date.now() - startTime}ms`,
|
|
1741
|
+
error
|
|
1742
|
+
);
|
|
1743
|
+
indexLoadState = "unloaded";
|
|
1744
|
+
indexLoadPromise = null;
|
|
1745
|
+
let hint;
|
|
1746
|
+
const details = error instanceof Error ? error.message : String(error);
|
|
1747
|
+
if (details.includes("ERR_REQUIRE_ESM") || details.includes("ES Module")) {
|
|
1748
|
+
hint = "The file or its dependencies are ESM-only. Switch to packages that dual-support CJS & ESM, or upgrade to Node 22.12+. If you must use Node 20, you may try Node 20.19\n\n";
|
|
1749
|
+
}
|
|
1750
|
+
const errorMsg = `${hint ?? ""}${details}`;
|
|
1751
|
+
const cause = error instanceof Error ? error : void 0;
|
|
1752
|
+
throw new Error(errorMsg, { cause });
|
|
1753
|
+
}
|
|
1754
|
+
})();
|
|
1755
|
+
return indexLoadPromise;
|
|
1664
1756
|
};
|
|
1665
1757
|
var getStreamingFunctions = async () => {
|
|
1666
|
-
loadIndex();
|
|
1758
|
+
await loadIndex();
|
|
1667
1759
|
const registry = getMooseInternal();
|
|
1668
1760
|
const transformFunctions = /* @__PURE__ */ new Map();
|
|
1669
1761
|
registry.streams.forEach((stream) => {
|
|
@@ -1690,7 +1782,7 @@ var getStreamingFunctions = async () => {
|
|
|
1690
1782
|
return transformFunctions;
|
|
1691
1783
|
};
|
|
1692
1784
|
var getApis2 = async () => {
|
|
1693
|
-
loadIndex();
|
|
1785
|
+
await loadIndex();
|
|
1694
1786
|
const apiFunctions = /* @__PURE__ */ new Map();
|
|
1695
1787
|
const registry = getMooseInternal();
|
|
1696
1788
|
const versionCountByName = /* @__PURE__ */ new Map();
|
|
@@ -1722,7 +1814,7 @@ var getApis2 = async () => {
|
|
|
1722
1814
|
return apiFunctions;
|
|
1723
1815
|
};
|
|
1724
1816
|
var getWorkflows2 = async () => {
|
|
1725
|
-
loadIndex();
|
|
1817
|
+
await loadIndex();
|
|
1726
1818
|
const registry = getMooseInternal();
|
|
1727
1819
|
return registry.workflows;
|
|
1728
1820
|
};
|
|
@@ -1756,7 +1848,7 @@ var getTaskForWorkflow = async (workflowName, taskName) => {
|
|
|
1756
1848
|
return task;
|
|
1757
1849
|
};
|
|
1758
1850
|
var getWebApps2 = async () => {
|
|
1759
|
-
loadIndex();
|
|
1851
|
+
await loadIndex();
|
|
1760
1852
|
return getMooseInternal().webApps;
|
|
1761
1853
|
};
|
|
1762
1854
|
|