2.0.8 • Published 5 years ago

workerjs-worker v2.0.8

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

workerjs-worker

npm npm npm Dependency Status

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-worker --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-worker

Step 2: Usage inside process

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

// Initialize communication to worker
worker.init();

// 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
worker.ready();

TODO

  • Define more clear names for parts of worker worker, process, etc.

  • Implement logging and add client to worker

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago