@zcong/node-worker-manager
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

node-worker-manager

NPM version NPM downloads CircleCI

Install

$ yarn add @zcong/node-worker-manager

Usage

quickly start with yarn example or yarn example:debug

// worker.js
const { parentPort } = require('worker_threads')

parentPort.on('message', msg => {
  // do something
  console.log(msg)
})
// main thread
const path = require('path')
const WorkerManager = require('@zcong/node-worker-manager')

const wm = new WorkerManager({
  workerPath: path.resolve(__dirname, './worker.js'),
  recreate: true,
  nums: 2
})

setInterval(() => {
  wm.dispatch('test worker')
}, 1000)

then run with command node --experimental-worker index.js

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

node-worker-manager © zcong1993, Released under the MIT License.
Authored and maintained by zcong1993 with help from contributors (list).

github.com/zcong1993 · GitHub @zcong1993

Readme

Keywords

none

Package Sidebar

Install

npm i @zcong/node-worker-manager

Weekly Downloads

1

Version

0.1.3

License

MIT

Unpacked Size

6.04 kB

Total Files

5

Last publish

Collaborators

  • zcong