Skip to content

workerJS/workerjs-mux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

workerjs-mux

npm npm npm

GitHub issues GitHub closed issues GitHub pull requests GitHub closed pull requests GitHub contributors

CLI Interface and library for starting and managing workers and forwarding commands and results.

Instalation

# You need project.json in same directory
npm install workerjs-mux --save

Usage

Step 1: Starting

# This starts worker on channel example and spawns ./examples/workerExample.js
WORKER=./examples/workerExample.js WORKERNAME=example ./node_modules/.bin/workerjs-mux

Step 2: Usage inside process

const worker = require("workerjs-mux");

// Subscribe on new tasks from worker
worker.on("task", function(task){
  // You just got new task

  setTimeout(function(){
    // Tell something to client
    task.publish(123);

    // Say to worker that you are finished.
    task.finish();
  }, Math.random() * 3000);
});

// Tell worker that you are ready to recieve tasks
worker.ready();

TODO

  • Implement logging and add client to worker

  • Implement node-ipc

About

Interface for starting worker and communication with client.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published