@nmakarov/cli-toolkit 0.70.0 → 0.71.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/cli-runner.cjs +74 -11
- package/dist/cli-runner.cjs.map +1 -1
- package/dist/cli-runner.js +74 -11
- package/dist/cli-runner.js.map +1 -1
- package/dist/index.cjs +90 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +86 -11
- package/dist/index.js.map +1 -1
- package/dist/tasks.cjs +90 -11
- package/dist/tasks.cjs.map +1 -1
- package/dist/tasks.js +86 -11
- package/dist/tasks.js.map +1 -1
- package/package.json +1 -1
package/dist/cli-runner.js
CHANGED
|
@@ -6507,6 +6507,59 @@ var LOGGER_RUNTIME_KEYS = [
|
|
|
6507
6507
|
"progressWithTimes",
|
|
6508
6508
|
"progressThrottleMs"
|
|
6509
6509
|
];
|
|
6510
|
+
var DEFAULT_RUNTIME_PARAM_SPECS = [
|
|
6511
|
+
{
|
|
6512
|
+
key: "maxParallel",
|
|
6513
|
+
type: "number",
|
|
6514
|
+
label: "Max parallel",
|
|
6515
|
+
description: "Worker-lane concurrency (how many tasks claim at once)"
|
|
6516
|
+
},
|
|
6517
|
+
{
|
|
6518
|
+
key: "pollMs",
|
|
6519
|
+
type: "number",
|
|
6520
|
+
label: "Poll ms",
|
|
6521
|
+
description: "Idle poll interval between claim attempts"
|
|
6522
|
+
},
|
|
6523
|
+
{
|
|
6524
|
+
key: "claimJitterMs",
|
|
6525
|
+
type: "number",
|
|
6526
|
+
label: "Claim jitter ms",
|
|
6527
|
+
description: "Random delay before worker claims (0 = off)"
|
|
6528
|
+
},
|
|
6529
|
+
{
|
|
6530
|
+
key: "scanLimit",
|
|
6531
|
+
type: "number",
|
|
6532
|
+
label: "Scan limit",
|
|
6533
|
+
description: "Max idle rows scanned per claim attempt"
|
|
6534
|
+
}
|
|
6535
|
+
];
|
|
6536
|
+
function mergeRuntimeParamSpecs(extra) {
|
|
6537
|
+
const byKey = new Map(DEFAULT_RUNTIME_PARAM_SPECS.map((s) => [s.key, { ...s }]));
|
|
6538
|
+
if (Array.isArray(extra)) {
|
|
6539
|
+
for (const raw of extra) {
|
|
6540
|
+
if (!raw || typeof raw !== "object") continue;
|
|
6541
|
+
const key = String(raw.key ?? "").trim();
|
|
6542
|
+
if (!key) continue;
|
|
6543
|
+
const prev = byKey.get(key) ?? {};
|
|
6544
|
+
const type = ["number", "boolean", "string"].includes(raw.type) ? raw.type : prev.type ?? "string";
|
|
6545
|
+
byKey.set(key, {
|
|
6546
|
+
key,
|
|
6547
|
+
type,
|
|
6548
|
+
label: String(raw.label ?? prev.label ?? key),
|
|
6549
|
+
description: raw.description != null ? String(raw.description) : prev.description != null ? String(prev.description) : void 0
|
|
6550
|
+
});
|
|
6551
|
+
}
|
|
6552
|
+
}
|
|
6553
|
+
return Array.from(byKey.values());
|
|
6554
|
+
}
|
|
6555
|
+
function runtimeValuesForSpecs(context, specs = DEFAULT_RUNTIME_PARAM_SPECS) {
|
|
6556
|
+
const rt = ensureTasksRuntime(context);
|
|
6557
|
+
const out = {};
|
|
6558
|
+
for (const s of specs) {
|
|
6559
|
+
if (rt[s.key] !== void 0) out[s.key] = rt[s.key];
|
|
6560
|
+
}
|
|
6561
|
+
return out;
|
|
6562
|
+
}
|
|
6510
6563
|
var CONTROL_LANE_TASK_NAMES = [
|
|
6511
6564
|
"stopRunner",
|
|
6512
6565
|
"stop",
|
|
@@ -6603,12 +6656,15 @@ async function applyRuntimeParam(context, key, value) {
|
|
|
6603
6656
|
const reg = context.servicesRegistry;
|
|
6604
6657
|
if (reg?.rowId && reg?.registryTable) {
|
|
6605
6658
|
try {
|
|
6606
|
-
const
|
|
6659
|
+
const specs = Array.isArray(context.tasksRuntimeParamSpecs) ? context.tasksRuntimeParamSpecs : DEFAULT_RUNTIME_PARAM_SPECS;
|
|
6660
|
+
const runtimeSnapshot = runtimeValuesForSpecs(context, specs);
|
|
6607
6661
|
for (const lk of LOOP_RUNTIME_KEYS) {
|
|
6608
|
-
if (runtime[lk] !== void 0
|
|
6662
|
+
if (runtime[lk] !== void 0 && runtimeSnapshot[lk] === void 0) {
|
|
6663
|
+
runtimeSnapshot[lk] = runtime[lk];
|
|
6664
|
+
}
|
|
6609
6665
|
}
|
|
6610
6666
|
await updateServicesRegistryMetadata(context, reg, {
|
|
6611
|
-
runtime:
|
|
6667
|
+
runtime: runtimeSnapshot,
|
|
6612
6668
|
runtimeUpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6613
6669
|
});
|
|
6614
6670
|
applied.push("servicesRegistry");
|
|
@@ -7291,18 +7347,25 @@ async function runTasksLoop(context, options) {
|
|
|
7291
7347
|
if (hbGroup) {
|
|
7292
7348
|
const hbIntervalMs = options.runnerHeartbeatIntervalMs ?? 1e4;
|
|
7293
7349
|
const staleMs = options.runnerHeartbeatStaleMs ?? 45e3;
|
|
7294
|
-
const
|
|
7350
|
+
const runtimeParamSpecs = mergeRuntimeParamSpecs(options.runnerRuntimeParams);
|
|
7351
|
+
context.tasksRuntimeParamSpecs = runtimeParamSpecs;
|
|
7295
7352
|
const defaultMeta = {
|
|
7296
7353
|
component: "tasks-runner",
|
|
7297
7354
|
allowedTasks: allowedTasks?.length ? allowedTasks.join(",") : "all",
|
|
7298
7355
|
paused: false,
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
pollMs: loop0.pollMs,
|
|
7302
|
-
claimJitterMs: loop0.claimJitterMs,
|
|
7303
|
-
scanLimit: loop0.scanLimit
|
|
7304
|
-
}
|
|
7356
|
+
runtimeParams: runtimeParamSpecs,
|
|
7357
|
+
runtime: runtimeValuesForSpecs(context, runtimeParamSpecs)
|
|
7305
7358
|
};
|
|
7359
|
+
const metadata = {
|
|
7360
|
+
...defaultMeta,
|
|
7361
|
+
...options.runnerMetadata && typeof options.runnerMetadata === "object" ? options.runnerMetadata : {}
|
|
7362
|
+
};
|
|
7363
|
+
if (!Array.isArray(metadata.runtimeParams) || metadata.runtimeParams.length === 0) {
|
|
7364
|
+
metadata.runtimeParams = defaultMeta.runtimeParams;
|
|
7365
|
+
}
|
|
7366
|
+
if (!metadata.runtime || typeof metadata.runtime !== "object") {
|
|
7367
|
+
metadata.runtime = defaultMeta.runtime;
|
|
7368
|
+
}
|
|
7306
7369
|
registryReg = await registerInServicesRegistry(context, {
|
|
7307
7370
|
queueName,
|
|
7308
7371
|
target,
|
|
@@ -7312,7 +7375,7 @@ async function runTasksLoop(context, options) {
|
|
|
7312
7375
|
staleMs,
|
|
7313
7376
|
groupMaxInstances: options.runnerGroupMaxInstances,
|
|
7314
7377
|
enforceMaxInstances: options.runnerEnforceMaxInstances ?? true,
|
|
7315
|
-
metadata
|
|
7378
|
+
metadata
|
|
7316
7379
|
});
|
|
7317
7380
|
context.servicesRegistry = registryReg;
|
|
7318
7381
|
runnerIdentity = {
|