New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

batch-cluster

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

batch-cluster - npm Package Compare versions

Comparing version 10.3.2 to 10.4.0

7

CHANGELOG.md

@@ -21,2 +21,9 @@ # Changelog

## v10.4.0
- ✨ If `healthCheckCommand` is set and any task fails, that child process will
have a health check run before being put back into rotation.
- 📦 Updated development dependencies and rebuild docs
## v10.3.2

@@ -23,0 +30,0 @@

2

dist/BatchCluster.d.ts

@@ -129,3 +129,2 @@ /// <reference types="node" />

startError: number;
timeout: number;
broken: number;

@@ -145,2 +144,3 @@ closed: number;

"stdout.error": number;
timeout: number;
tooMany: number;

@@ -147,0 +147,0 @@ unhealthy: number;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

@@ -13,3 +13,3 @@ "use strict";

};
var _BatchProcess_instances, _BatchProcess_lastHealthCheck, _BatchProcess_healthCheckFailures, _BatchProcess_logger, _BatchProcess_lastJobFinshedAt, _BatchProcess_starting, _BatchProcess_exited, _BatchProcess_whyNotHealthy, _BatchProcess_taskCount, _BatchProcess_currentTask, _BatchProcess_currentTaskTimeout, _BatchProcess_endPromise, _BatchProcess_execTask, _BatchProcess_end, _BatchProcess_awaitNotRunning, _BatchProcess_onTimeout, _BatchProcess_onError, _BatchProcess_onStderr, _BatchProcess_onStdout, _BatchProcess_clearCurrentTask;
var _BatchProcess_instances, _BatchProcess_lastHealthCheck, _BatchProcess_healthCheckFailures, _BatchProcess_logger, _BatchProcess_lastJobFinshedAt, _BatchProcess_lastJobFailed, _BatchProcess_starting, _BatchProcess_exited, _BatchProcess_whyNotHealthy, _BatchProcess_taskCount, _BatchProcess_currentTask, _BatchProcess_currentTaskTimeout, _BatchProcess_endPromise, _BatchProcess_execTask, _BatchProcess_end, _BatchProcess_awaitNotRunning, _BatchProcess_onTimeout, _BatchProcess_onError, _BatchProcess_onStderr, _BatchProcess_onStdout, _BatchProcess_clearCurrentTask;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -44,3 +44,4 @@ exports.BatchProcess = void 0;

_BatchProcess_logger.set(this, void 0);
_BatchProcess_lastJobFinshedAt.set(this, Date.now()
_BatchProcess_lastJobFinshedAt.set(this, Date.now());
_BatchProcess_lastJobFailed.set(this, false
// Only set to true when `proc.pid` is no longer in the process table.

@@ -53,3 +54,6 @@ );

// pidExists() returned false
_BatchProcess_exited.set(this, false);
_BatchProcess_exited.set(this, false
// override for .whyNotHealthy()
);
// override for .whyNotHealthy()
_BatchProcess_whyNotHealthy.set(this, void 0);

@@ -230,8 +234,15 @@ this.failedTaskCount = 0;

maybeRunHealthcheck() {
if (this.ready &&
this.opts.healthCheckCommand != null &&
this.opts.healthCheckIntervalMillis > 0 &&
Date.now() - __classPrivateFieldGet(this, _BatchProcess_lastHealthCheck, "f") > this.opts.healthCheckIntervalMillis) {
const hcc = this.opts.healthCheckCommand;
// if there's no health check command, no-op.
if (hcc == null || (0, String_1.blank)(hcc))
return;
// if the prior health check failed, .ready will be false
if (!this.ready)
return;
if (__classPrivateFieldGet(this, _BatchProcess_lastJobFailed, "f") ||
(this.opts.healthCheckIntervalMillis > 0 &&
Date.now() - __classPrivateFieldGet(this, _BatchProcess_lastHealthCheck, "f") >
this.opts.healthCheckIntervalMillis)) {
__classPrivateFieldSet(this, _BatchProcess_lastHealthCheck, Date.now(), "f");
const t = new Task_1.Task(this.opts.healthCheckCommand, Parser_1.SimpleParser);
const t = new Task_1.Task(hcc, Parser_1.SimpleParser);
t.promise

@@ -274,3 +285,3 @@ .catch((err) => {

exports.BatchProcess = BatchProcess;
_BatchProcess_lastHealthCheck = new WeakMap(), _BatchProcess_healthCheckFailures = new WeakMap(), _BatchProcess_logger = new WeakMap(), _BatchProcess_lastJobFinshedAt = new WeakMap(), _BatchProcess_starting = new WeakMap(), _BatchProcess_exited = new WeakMap(), _BatchProcess_whyNotHealthy = new WeakMap(), _BatchProcess_taskCount = new WeakMap(), _BatchProcess_currentTask = new WeakMap(), _BatchProcess_currentTaskTimeout = new WeakMap(), _BatchProcess_endPromise = new WeakMap(), _BatchProcess_instances = new WeakSet(), _BatchProcess_execTask = function _BatchProcess_execTask(task) {
_BatchProcess_lastHealthCheck = new WeakMap(), _BatchProcess_healthCheckFailures = new WeakMap(), _BatchProcess_logger = new WeakMap(), _BatchProcess_lastJobFinshedAt = new WeakMap(), _BatchProcess_lastJobFailed = new WeakMap(), _BatchProcess_starting = new WeakMap(), _BatchProcess_exited = new WeakMap(), _BatchProcess_whyNotHealthy = new WeakMap(), _BatchProcess_taskCount = new WeakMap(), _BatchProcess_currentTask = new WeakMap(), _BatchProcess_currentTaskTimeout = new WeakMap(), _BatchProcess_endPromise = new WeakMap(), _BatchProcess_instances = new WeakSet(), _BatchProcess_execTask = function _BatchProcess_execTask(task) {
var _a;

@@ -472,2 +483,3 @@ var _b;

var _a;
__classPrivateFieldSet(this, _BatchProcess_lastJobFailed, (task === null || task === void 0 ? void 0 : task.state) === "rejected", "f");
if (task != null && task.taskId !== ((_a = __classPrivateFieldGet(this, _BatchProcess_currentTask, "f")) === null || _a === void 0 ? void 0 : _a.taskId))

@@ -474,0 +486,0 @@ return;

@@ -15,7 +15,7 @@ /**

/**
* If provided, and healthCheckIntervalMillis is greater than 0, this
* command will be sent to child processes.
* If provided, and healthCheckIntervalMillis is greater than 0, or the
* previous task failed, this command will be sent to child processes.
*
* If the command outputs to stderr or returns a fail string, the process
* will be considered unhealthy and recycled.
* If the command outputs to stderr or returns a fail string, the process will
* be considered unhealthy and recycled.
*/

@@ -22,0 +22,0 @@ healthCheckCommand?: string | undefined;

@@ -14,5 +14,10 @@ declare type LogFunc = (message: string, ...optionalParams: any[]) => void;

/**
* Default `Logger` implementation. `debug` and `info` go to
* util.debuglog("batch-cluster")`. `warn` and `error` go to `console.warn` and
* `console.error`.
* Default `Logger` implementation.
*
* - `debug` and `info` go to {@link util.debuglog}("batch-cluster")`.
*
* - `warn` and `error` go to `console.warn` and `console.error`.
*
* @see https://nodejs.org/api/util.html#util_util_debuglog_section
* @see https://nodejs.org/api/console.html
*/

@@ -19,0 +24,0 @@ export declare const ConsoleLogger: Logger;

@@ -20,5 +20,10 @@ "use strict";

/**
* Default `Logger` implementation. `debug` and `info` go to
* util.debuglog("batch-cluster")`. `warn` and `error` go to `console.warn` and
* `console.error`.
* Default `Logger` implementation.
*
* - `debug` and `info` go to {@link util.debuglog}("batch-cluster")`.
*
* - `warn` and `error` go to `console.warn` and `console.error`.
*
* @see https://nodejs.org/api/util.html#util_util_debuglog_section
* @see https://nodejs.org/api/console.html
*/

@@ -25,0 +30,0 @@ exports.ConsoleLogger = Object.freeze({

{
"name": "batch-cluster",
"version": "10.3.2",
"version": "10.4.0",
"description": "Manage a cluster of child processes",

@@ -51,5 +51,5 @@ "main": "dist/BatchCluster.js",

"@types/mocha": "^9.1.0",
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"@types/node": "^17.0.23",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"chai": "^4.3.6",

@@ -59,6 +59,6 @@ "chai-as-promised": "^7.1.1",

"chai-withintoleranceof": "^1.0.1",
"eslint": "^8.10.0",
"eslint": "^8.12.0",
"eslint-plugin-import": "^2.25.4",
"mocha": "^9.2.1",
"prettier": "^2.5.1",
"mocha": "^9.2.2",
"prettier": "^2.6.1",
"rimraf": "^3.0.2",

@@ -70,5 +70,5 @@ "seedrandom": "^3.0.5",

"timekeeper": "^2.2.0",
"typedoc": "^0.22.12",
"typescript": "~4.5.5"
"typedoc": "^0.22.13",
"typescript": "~4.6.3"
}
}

@@ -53,27 +53,29 @@ # batch-cluster

1. Create a singleton instance of
[BatchCluster](https://photostructure.github.io/batch-cluster.js/classes/batchcluster.html).
[BatchCluster](https://photostructure.github.io/batch-cluster.js/classes/BatchCluster.html).
Note the [constructor
options](https://photostructure.github.io/batch-cluster.js/classes/batchcluster.html#constructor)
options](https://photostructure.github.io/batch-cluster.js/classes/BatchCluster.html#constructor)
takes a union type of
- [ChildProcessFactory](https://photostructure.github.io/batch-cluster.js/interfaces/childprocessfactory.html)
- [ChildProcessFactory](https://photostructure.github.io/batch-cluster.js/interfaces/ChildProcessFactory.html)
and
- [BatchProcessOptions](https://photostructure.github.io/batch-cluster.js/interfaces/batchprocessoptions.html),
- [BatchProcessOptions](https://photostructure.github.io/batch-cluster.js/interfaces/BatchProcessOptions.html),
both of which have no defaults, and
- [BatchClusterOptions](https://photostructure.github.io/batch-cluster.js/classes/batchclusteroptions.html),
- [BatchClusterOptions](https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html),
which has defaults that may or may not be relevant to your application.
1. The [default](https://photostructure.github.io/batch-cluster.js/modules.html#logger) logger
1. The [default logger](https://photostructure.github.io/batch-cluster.js/interfaces/Logger.html)
writes warning and error messages to `console.warn` and `console.error`. You
can change this to your logger by using
[setLogger](https://photostructure.github.io/batch-cluster.js/modules.html#setlogger).
[setLogger](https://photostructure.github.io/batch-cluster.js/modules.html#setLogger) or by providing a logger to the `BatchCluster` constructor.
1. Implement the [Parser](https://photostructure.github.io/batch-cluster.js/interfaces/parser.html)
1. Implement the [Parser](https://photostructure.github.io/batch-cluster.js/interfaces/Parser.html)
class to parse results from your child process.
1. Construct a [Task](https://photostructure.github.io/batch-cluster.js/classes/task.html) with the desired command and
the parser you built in the previous step, and submit it to your BatchCluster
singleton's
[enqueueTask](https://photostructure.github.io/batch-cluster.js/classes/batchcluster.html#enqueuetask) method.
1. Construct or extend the
[Task](https://photostructure.github.io/batch-cluster.js/classes/Task.html)
class with the desired command and the parser you built in the previous
step, and submit it to your BatchCluster's
[enqueueTask](https://photostructure.github.io/batch-cluster.js/classes/BatchCluster.html#enqueueTask)
method.

@@ -80,0 +82,0 @@ See

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc