# bauer-cluster

> Just another cluster library.

Latest version **1.3.8** (published 2015-11-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install bauer-cluster
pnpm add bauer-cluster
yarn add bauer-cluster
bun add bauer-cluster
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.8 |
| Published | 2015-11-26 |
| First published | 2014-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Yuri Neves Silveira |
| Maintainers | yneves |
| Keywords | multi-thread, multi-core, process, fork, multi-process, cluster |

## Links

- npm: https://www.npmjs.com/package/bauer-cluster
- Repository: https://github.com/yneves/node-bauer-cluster
- Issues: https://github.com/yneves/node-bauer-cluster/issues
- npm.io page: https://npm.io/package/bauer-cluster

## Dependencies (2)

- [node-uuid](https://npm.io/package/node-uuid.md) ^1.4.7
- [bauer-factory](https://npm.io/package/bauer-factory.md) ^2.0.4

## Recent versions

- 1.3.8 (latest) — 2015-11-26
- 1.3.7 — 2015-08-29
- 1.3.6 — 2015-08-08
- 1.3.5 — 2015-07-31
- 1.3.4 — 2015-07-25
- 1.3.3 — 2015-07-25
- 1.3.2 — 2015-07-19
- 1.3.1 — 2015-07-18
- 1.3.0 — 2015-07-12
- 1.2.4 — 2015-07-05
- 1.2.3 — 2015-07-05
- 1.2.2 — 2015-06-09
- 1.2.1 — 2015-06-09
- 1.1.1 — 2015-05-24
- 1.1.0 — 2015-05-24
- … 5 more at https://npm.io/package/bauer-cluster/versions

## README

# bauer-cluster

Multi-process development library.

## Installation

```
npm install bauer-cluster
```

## Usage

```js
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](./LICENSE)

---
_Source: https://npm.io/package/bauer-cluster · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
