Batch Engine
Ultra-lightweight, asynchronous and fault-tolerant batch engine for file processing with concurrency control.
Installation
$ npm i batch-engine
API
Check this minimum batch-engine example project.
const BatchStep = ;const BatchJob = ;const BatchRecord = ;const fs = ;const randomTime = 0; { super; // Just for this example proposes. thiscount = 0; } { // Maybe open a file. } async { thiscount++; if thiscount <= 300 return thiscount Stringthiscount; return null; } { // Maybe close a file. } async { return { ; }; } async { return { ; }; } async { return { ; }; } async { return { fs; }; } // Run MyBatchJob name'test-batch' ; // When some records failed, you can retry that ones./* (new MyBatchJob.Builder(MyBatchJob)) .concurrencyMultiplier(8) .name('test-batch-retry') .addStep(new MyBatchStep1("Join 3 records using -", 3)) .addStep(new MyBatchStep2("Join 2 payloads using **", 2)) .addStep(new MyBatchStep3("Join 4 payloads using |||", 4)) .addStep(new MyBatchStep4("Put the result in an output file", 1)) .build() .retry(/path/to/execution/context);*/
Debug
Debug for visual code using NODE_DEBUG.
"version": "0.2.0" "configurations": "type": "node" "request": "launch" "name": "batch-engine-example" "skipFiles": "<node_internals>/**" "env": "NODE_DEBUG" : "[BATCH-ENGINE:CORE]" "program": "${workspaceFolder}/example/example-batch-engine.js"
License
Copyright (c) 2020 contributors (cf. CONTRIBUTORS.md).
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.