@graphql-mesh/cli
Version:
27 lines (26 loc) • 705 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMaxConcurrency = getMaxConcurrency;
/* eslint-disable import/no-nodejs-modules */
const os_1 = require("os");
function getFreeMemInGb() {
return (0, os_1.freemem)() / 1024 ** 3;
}
function getMaxConcurrencyPerMem() {
return parseInt(String(getFreeMemInGb()));
}
function getMaxConcurrencyPerCpu() {
try {
return (0, os_1.availableParallelism)();
}
catch (e) {
return (0, os_1.cpus)().length;
}
}
function getMaxConcurrency() {
const result = Math.min(getMaxConcurrencyPerMem(), getMaxConcurrencyPerCpu());
if (result < 1) {
return 1;
}
return result;
}
;