batch-cluster
Advanced tools
Comparing version 4.2.0 to 4.3.0
@@ -20,2 +20,9 @@ # Changelog | ||
## v4.3.0 | ||
- ✨ If your tasks return interim progress and you want to capture that data | ||
as it happens, BatchCluster now emits `taskData` events with the data and the | ||
current task (which may be undefined) as soon as the stream data is emitted. | ||
- 📦 Pulled in latest dependency versions | ||
## v4.2.0 | ||
@@ -22,0 +29,0 @@ |
@@ -171,2 +171,7 @@ /// <reference types="node" /> | ||
/** | ||
* Emitted when tasks receive data, which may be partial chunks from the task | ||
* stream. | ||
*/ | ||
on(event: "taskData", listener: (data: Buffer | string, task: Task<any> | undefined) => void): void; | ||
/** | ||
* Emitted when a task has an error | ||
@@ -173,0 +178,0 @@ */ |
@@ -296,2 +296,5 @@ "use strict"; | ||
onStartError: function (err) { return _this.onStartError(err); }, | ||
onTaskData: function (data, task) { | ||
return _this.emitter.emit("taskData", data, task); | ||
}, | ||
onTaskError: function (err, task) { return _this.emitter.emit("taskError", err, task); }, | ||
@@ -298,0 +301,0 @@ onInternalError: function (err) { return _this.onInternalError(err); }, |
@@ -10,2 +10,3 @@ /// <reference types="node" /> | ||
onIdle(): void; | ||
onTaskData(data: Buffer | string, task: Task<any> | undefined): void; | ||
onTaskError(error: Error, task: Task<any>): void; | ||
@@ -12,0 +13,0 @@ onStartError(error: Error): void; |
@@ -366,2 +366,3 @@ "use strict"; | ||
BatchCluster_1.logger().trace(this.name + ".onData(" + data.toString() + ")"); | ||
this.observer.onTaskData(data, this.currentTask); | ||
this.buff = this.buff + data.toString(); | ||
@@ -368,0 +369,0 @@ var pass = this.opts.passRE.exec(this.buff); |
{ | ||
"name": "batch-cluster", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "Manage a cluster of child processes", | ||
@@ -35,6 +35,6 @@ "main": "dist/BatchCluster.js", | ||
"@types/mocha": "^5.2.5", | ||
"@types/node": "^10.7.1", | ||
"@types/node": "^10.9.4", | ||
"chai": "^4.1.2", | ||
"chai-as-promised": "^7.1.1", | ||
"chai-string": "^1.4.0", | ||
"chai-string": "^1.5.0", | ||
"chai-withintoleranceof": "^1.0.1", | ||
@@ -45,9 +45,9 @@ "mocha": "^5.2.0", | ||
"seedrandom": "^2.4.4", | ||
"serve": "^9.6.0", | ||
"source-map-support": "^0.5.8", | ||
"serve": "^10.0.1", | ||
"source-map-support": "^0.5.9", | ||
"timekeeper": "^2.1.2", | ||
"typedoc": "^0.12.0", | ||
"typescript": "^3.0.1", | ||
"wtfnode": "^0.7.0" | ||
"typescript": "^3.0.3", | ||
"wtfnode": "^0.7.1" | ||
} | ||
} |
@@ -26,5 +26,4 @@ # batch-cluster | ||
This package powers | ||
[exiftool-vendored](https://exiftool-vendored.js.org/), whose | ||
source you can examine as an example consumer. | ||
This package powers [exiftool-vendored](https://exiftool-vendored.js.org/), | ||
whose source you can examine as an example consumer. | ||
@@ -47,5 +46,2 @@ ## Installation | ||
_If links are broken, please read this on | ||
[batch-cluster.js.org](https://batch-cluster.js.org/)._ | ||
The child process must use `stdin` and `stdout` for control/response. | ||
@@ -55,25 +51,27 @@ BatchCluster will ensure a given process is only given one task at a time. | ||
1. Create a singleton instance of | ||
[BatchCluster](/classes/batchcluster.html). | ||
[BatchCluster](https://batch-cluster.js.org/classes/batchcluster.html). | ||
Note the [constructor | ||
options](/classes/batchcluster.html#constructor) takes a union | ||
type of | ||
options](https://batch-cluster.js.org/classes/batchcluster.html#constructor) | ||
takes a union type of | ||
- [ChildProcessFactory](/interfaces/childprocessfactory.html) and | ||
- [BatchProcessOptions](/interfaces/batchprocessoptions.html), | ||
- [ChildProcessFactory](https://batch-cluster.js.org/interfaces/childprocessfactory.html) | ||
and | ||
- [BatchProcessOptions](https://batch-cluster.js.org/interfaces/batchprocessoptions.html), | ||
both of which have no defaults, and | ||
- [BatchClusterOptions](/classes/batchclusteroptions.html), | ||
- [BatchClusterOptions](https://batch-cluster.js.org/classes/batchclusteroptions.html), | ||
which has defaults that may or may not be relevant to your application. | ||
1. The [default](/modules/logger.html) logger writes warning and | ||
error messages to `console.warn` and `console.error`. You can change this to | ||
your logger by using [setLogger](/globals.html#setlogger). | ||
1. The [default](https://batch-cluster.js.org/modules/logger.html) logger | ||
writes warning and error messages to `console.warn` and `console.error`. You | ||
can change this to your logger by using | ||
[setLogger](/globals.html#setlogger). | ||
1. Implement the [Parser](/globals.html#parser) class to parse results from your child | ||
process. | ||
1. Implement the [Parser](https://batch-cluster.js.org/globals.html#parser) | ||
class to parse results from your child process. | ||
1. Construct a [Task](/classes/task.html) with the desired command and | ||
1. Construct a [Task](https://batch-cluster.js.org/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](/classes/_batchcluster_.batchcluster.html#enqueuetask) method. | ||
[enqueueTask](https://batch-cluster.js.org/classes/batchcluster#enqueuetask) method. | ||
@@ -80,0 +78,0 @@ See |
Sorry, the diff of this file is not supported yet
172775
2059
79