# consistent-hashing-server

> consistent hashing servers,monitored by zookeeper

Latest version **0.1.3** (published 2017-05-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install consistent-hashing-server
pnpm add consistent-hashing-server
yarn add consistent-hashing-server
bun add consistent-hashing-server
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2017-05-10 |
| First published | 2016-10-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+5 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Zhou Peng |
| Maintainers | starking1995 |
| Keywords | consistend-hashing, zookeeper, pm2 |

## Links

- npm: https://www.npmjs.com/package/consistent-hashing-server
- Repository: https://github.com/starking1991/consistent-hashing-server
- Homepage: https://github.com/starking1991/consistent-hashing-server#readme
- Issues: https://github.com/starking1991/consistent-hashing-server/issues
- npm.io page: https://npm.io/package/consistent-hashing-server

## Dependencies (6)

- [pm2](https://npm.io/package/pm2.md) 2.0.18
- [debug](https://npm.io/package/debug.md) ~2.2.0
- [assert](https://npm.io/package/assert.md) 1.4.1
- [promise](https://npm.io/package/promise.md) ~7.0.4
- [underscore](https://npm.io/package/underscore.md) ~1.8.3
- [node-zookeeper-client](https://npm.io/package/node-zookeeper-client.md) 0.2.2

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2017-05-10
- 0.1.2 — 2016-10-18
- 0.1.1 — 2016-10-18
- 0.1.0 — 2016-10-18

## README

npm install

npm install pm2 -g

npm test : test register servers

npm stop : stop test

example

pm2 config

{
  "apps": [
    {

      "name": "connector1",
      "max_memory_restart": "2024M",
      "log_date_format": "YYYY-MM-DD HH:mm",
      "script": "./main/connector/connector.js",
      "out_file": "./log/app.log",
      "error_file": "./log/err.log",
       "port": "7081",
       "env": {
        "SERVER_TYPE":"connector",
        "DEBUG":"* node ./main/connector/connector.js",
        "PORT": "7081",
        "HOST":"192.168.1.127"
      }
    },
    {
      "name": "connector2",
      "max_memory_restart": "2024M",
      "log_date_format": "YYYY-MM-DD HH:mm",
      "script": "./main/connector/connector.js",
      "out_file": "./log/app.log",
      "error_file": "./log/err.log",
      "port": "7082",
      "env": {
        "SERVER_TYPE":"connector",
        "DEBUG":"* node ./main/connector/connector.js",
        "PORT": "7082",
        "HOST":"192.168.1.127"
      }
    },
    {
      "name": "connector3",
      "max_memory_restart": "2024M",
      "log_date_format": "YYYY-MM-DD HH:mm",
      "script": "./main/connector/connector.js",
      "out_file": "./log/app.log",
      "error_file": "./log/err.log",
      "port": "7083",
      "env": {
        "SERVER_TYPE":"connector",
        "DEBUG":"* node ./main/connector/connector.js",
        "PORT": "7083",
        "HOST":"192.168.1.127"
      }
    },
    {
      "name": "connector4",
      "max_memory_restart": "2024M",
      "log_date_format": "YYYY-MM-DD HH:mm",
      "script": "./main/connector/connector.js",
      "out_file": "./log/app.log",
      "error_file": "./log/err.log",
      "port": "7084",
      "env": {
        "SERVER_TYPE":"connector",
        "DEBUG":"* node ./main/connector/connector.js",
        "PORT": "7084",
        "HOST":"192.168.1.127"
      }
    },
    {
      "name": "connector5",
      "max_memory_restart": "2024M",
      "log_date_format": "YYYY-MM-DD HH:mm",
      "script": "./main/connector/connector.js",
      "out_file": "./log/app.log",
      "error_file": "./log/err.log",
      "port": "7085",
      "env": {
        "SERVER_TYPE":"connector",
        "DEBUG":"* node ./main/connector/connector.js",
        "PORT": "7085",
        "HOST":"192.168.1.127"
      }
    }
  ]
}

and connector.js like

var ServerFactory = require("consistent-hashing-server");
var serverFactory = new ServerFactory(host+":"+port,"/connectors",5,constants.zookeeper_url);
serverFactory.getServer(key);


and you can test like

run test-add-or-stop-a-server.js

serverFactory.getServer(10) return localhost:7083

you can pm2 stop connector3,and wait the zookeeper timeout

serverFactory.getServer(10) return localhost:test

then start connector3

serverFactory.getServer(10) return localhost:7084

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