Skip to content

Commit

Permalink
change parallelizer function name to a more friendly name
Browse files Browse the repository at this point in the history
  • Loading branch information
Edujugon committed Mar 20, 2023
1 parent 92bffa9 commit 0bd74fe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Node Parallelizer
A NodeJS package for running code in parallel. Initially created to provide multiprocessing in an AWS Lambda function, it can be used in any NodeJS environment.
A NodeJS package for running code in parallel. Initially created to provide multiprocessing in an AWS Lambda function, but it can be used in any NodeJS environment.

## Supported parallelizers
- Child Process
Expand All @@ -15,7 +15,7 @@ The package can detect the number of vCPU cores allocated to your Lambda functio

It uses the Lambda function environment `/tmp` folder to create the required module that runs in the child.

When you call the `createChildProcessFromFile` method outside of the Lambda handler function, it will reuse the child processes across the different invocations within a Lambda instance, improving performance. Furthermore, if the package detects a disconnection of any of the child processes, it will recreate it automatically without affecting the execution.
When you call the `parallelizerFunction` method outside of the Lambda handler function, it will reuse the child processes across the different invocations within a Lambda instance, improving performance. Furthermore, if the package detects a disconnection of any of the child processes, it will recreate it automatically without affecting the execution.

## Installation
To add this package to your dependency list, run:
Expand All @@ -34,7 +34,7 @@ npm i node-parallelizer --save
- `processesPerCPU` (Number) (Default value: 1): If the `maxProcesses` is set to `false`, this parameter defines the amount of processes per CPU.
- `debug` (Boolean) (Default value: false): Enables the internal logs for debuggin purposes.
#### Main methods
`createChildProcessFromFile({ filePath, processBatchFunctionName })`
`parallelizerFunction({ filePath, processBatchFunctionName })`

**Parameters**
- `filePath` (String): The absolute path to the file that contains the function that will be executed with the subset.
Expand Down Expand Up @@ -65,7 +65,7 @@ const { ChildProcess } = require("node-parallelizer");
// Creates a new child process instance.
const childProcess = new ChildProcess();
// Creates child processes based on your code.
childProcess.createChildProcessFromFile({ filePath: "/var/task/src/my-child-code.js", processBatchFunctionName: 'batchProcessor' });
childProcess.parallelizerFunction({ filePath: "/var/task/src/my-child-code.js", processBatchFunctionName: 'batchProcessor' });

module.exports.handler = async(event) => {
// Run batch in parallel
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "node-parallelizer",
"version": "1.1.2",
"description": "A NodeJS package for running code in parallel. Initially created to provide multiprocessing in an AWS Lambda function, it can be used in any NodeJS environment.",
"version": "1.1.3",
"description": "A NodeJS package for running code in parallel. Initially created to provide multiprocessing in an AWS Lambda function, but it can be used in any NodeJS environment.",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion src/child-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ChildProcess {
this._createChildProcesses();
}

createChildProcessFromFile = ({ filePath, processBatchFunctionName }) => {
parallelizerFunction = ({ filePath, processBatchFunctionName }) => {
const finalChildCode = `const {${processBatchFunctionName}: processBatch} = require('${filePath}'); ${templateChildCode}`
this.childFile = this._createChildFile(finalChildCode);

Expand Down

0 comments on commit 0bd74fe

Please sign in to comment.