# prettygoat-cluster

> Workload distribution and failover for [prettygoat](https://github.com/tierratelematics/prettygoat) based on [ringpop](https://github.com/uber/ringpop-node).

Latest version **4.3.1** (published 2018-02-13) · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.3.1 |
| Published | 2018-02-13 |
| First published | 2017-02-10 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 93.2 KB |
| Known vulnerabilities | 0 (+12 in 2 direct dependencies) |
| Install scripts | no |
| Maintainers | tierratelematics |

## Links

- npm: https://www.npmjs.com/package/prettygoat-cluster
- npm.io page: https://npm.io/package/prettygoat-cluster

## Dependencies (9)

- [rxjs](https://npm.io/package/rxjs.md) ~5.4.2
- [lodash](https://npm.io/package/lodash.md) ~4.13.1
- [hammock](https://npm.io/package/hammock.md) ~2.0.1
- [ringpop](https://npm.io/package/ringpop.md) ~10.18.0
- [tchannel](https://npm.io/package/tchannel.md) ~3.9.0
- [inversify](https://npm.io/package/inversify.md) ^4.3.0
- [socket.io](https://npm.io/package/socket.io.md) ~1.4.6
- [socket.io-redis](https://npm.io/package/socket.io-redis.md) ~3.1.0
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) 0.1.8

## Recent versions

- 4.3.1 (latest) — 2018-02-13
- 4.3.0 — 2018-01-24
- 4.2.0 — 2018-01-23
- 3.2.6 — 2018-01-03
- 3.2.5 — 2018-01-03
- 4.1.1 — 2018-01-02
- 3.2.4 — 2018-01-02
- 4.1.0 — 2017-12-22
- 4.0.0 — 2017-12-20
- 3.2.3 — 2017-12-18
- 3.2.2 — 2017-12-11
- 3.2.1 — 2017-12-11
- 3.2.0 — 2017-12-11
- 3.1.5 — 2017-12-06
- 3.1.4 — 2017-12-06
- … 16 more at https://npm.io/package/prettygoat-cluster/versions

## README

# Prettygoat-cluster

Workload distribution and failover for [prettygoat](https://github.com/tierratelematics/prettygoat) based on [ringpop](https://github.com/uber/ringpop-node).

## Installation

`
$ npm install prettygoat-cluster
`

## Usage

Register the module with prettygoat

```typescript
import {ClusteredEngine} from "prettygoat-cluster";

let engine = new ClusteredEngine();
//Register projections...
engine.run();
```

This will run the engine with the default cluster configuration (one node).
If you need to run different instances on the same machine just drop this configuration:

```typescript
container.bind<IClusterConfig>("IClusterConfig").toConstantValue({
    nodes: ["127.0.0.1:4000", "127.0.0.1:4001"],
    port: 4000,
    host: "127.0.0.1",
    forks: 2
});
```

## Load balancing

To load balance HTTP and Websockets among the cluster, use [loadbalancer](https://www.npmjs.com/package/loadbalancer).

Example configuration:

```json
{
  "sourcePort": 8000,
  "stickiness": false,
  "targets": [
    {
      "host": "127.0.0.1",
      "port": 3000
    },
    {
      "host": "127.0.0.1",
      "port": 3001
    }
  ]
}
```

## Socket.io clustering

In order to correctly send notifications between all the instances of socket.io server, you need to provide a Redis client.

```typescript
const Redis = require("ioredis");

container.bind("RedisClient").toConstantValue(new Redis.Cluster([
  {
    port: 6380,
    host: '127.0.0.1'
  },
  {
    port: 6381,
    host: '127.0.0.1'
  }
]));
```

## License

Copyright 2016 Tierra SpA

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

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