0.1.3 • Published 6 years ago

@zcong/node-worker-manager v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

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

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago