Socket
Book a DemoInstallSign in
Socket

bauer-cluster

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bauer-cluster

Just another cluster library.

1.3.8
latest
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

bauer-cluster

Multi-process development library.

Installation

npm install bauer-cluster

Usage

var Cluster = require("bauer-cluster").Cluster;

var myCluster = new Cluster();

// executed when in main process
myCluster.master(function() {
  
  this === myCluster // true
  
  this.isMaster; // true
  this.isWorker; // false

  var worker = this.fork("one","two");

  worker.args; // ["one","two"]
  worker.process; // child process produced by fork
  
  worker.on("message",function(message) {
    if (message.pong) {
      worker.send({ ping: true });
    }
  });
  
  worker.send({ ping: true });

});

// executed when in child process
myCluster.worker(function(worker) {

  this === myCluster // true
  
  this.isMaster; // false
  this.isWorker; // true

  worker.args; // ["one","two"]
  worker.process; // global process object
  
  worker.on("message",function(message) {
    if (message.ping) {
      worker.send({ pong: true });
    }
  });

});

myCluster.start();

API Summary

  • Cluster

    • new Cluster() :Cluster
    • .getWorkerArgsOffset() :Number
    • .require(name String) :void
    • .master(callback Function) :void
    • .worker(callback Function) :void
    • .start() :void
    • .fork(arg0, arg1, ...) :Worker
    • .removeWorker(worker Worker) :void
    • .createWorker(uuid String, args Array) :Worker
    • .createWorker(uuid String, args Array, process Object) :Worker
  • Worker

    • new Worker(cluster Cluster, uuid String, args Array, process Object) :Worker
    • .setupProcess(proc) :void
    • .require(name String) :void
    • .kill(signal Number) :void
    • .die(reason Number|Error) :void
    • .send(message Object) :void
    • .receive(message Object) :void

License

MIT

Keywords

multi-thread

FAQs

Package last updated on 26 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.