• Stars
    star
    139
  • Rank 262,954 (Top 6 %)
  • Language
    C++
  • Created about 14 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Consistent Hashing C++ add-on for node.js

node-hash-ring - Consistent Hashing C++ Add-on for node.js


See this blog post for more information.

Installation

Via npm:

$ npm install hash_ring

Via git:

$ git clone http://github.com/bnoguchi/node-hash-ring.git
$ cd node-hash-ring
$ npm run build

Example

var HashRing = require("hash_ring");

// Create a cluster of 3 servers weighted so that 127.0.0.2:8080 stores twice as many 
// keys as 127.0.0.1:8080, and 127.0.0.3:8080 stores 4x as many keys as 127.0.0.1:8080
// and 2x as many keys as 127.0.0.2:8080

var ring = new HashRing({"127.0.0.1:8080": 1, "127.0.0.2:8080": 2, "127.0.0.3:8080":4});
console.log(ring.getNode("users:102") ); // Should be 127.0.0.3:8080

See ./test/test_distribution.js for another example:

$ node test/test_distribution.js

Key Hashing

By default, MD5 is used to hash keys. You can choose another hasher.

var HashRing = require("hash_ring");

var ring = new HashRing({"127.0.0.1:8080": 1, "127.0.0.2:8080": 2, "127.0.0.3:8080":4}, "murmur");

Supported hashers are:

Tests

To run the tests:

$ npm test

License

MIT License


Author

Brian Noguchi

More Repositories

1

everyauth

node.js auth package (password, facebook, & more) for Connect and Express apps
JavaScript
3,504
star
2

mongoose-auth

User authentication plugin for mongoose nodejs orm
JavaScript
742
star
3

hooks-js

Augment your methods with pre and post hooks
JavaScript
284
star
4

mongoose-types

Additional handy types for mongoose
JavaScript
171
star
5

redis-node

A Redis client for node.js
JavaScript
132
star
6

Socket.IO-connect

Use Socket.IO-node as middleware in your Connect app
JavaScript
83
star
7

logoot

JavaScript implementation of the Logoot CRDT
JavaScript
23
star
8

node-notify-send

Ubuntu growl-like notifications for node.js
JavaScript
20
star
9

google-refresh-token

Refreshes Google OAuth 2 Access Tokens
JavaScript
16
star
10

class-js

Simple OO Class factory
JavaScript
14
star
11

browser-require

The easiest way to require NPM and CommonJS modules from your browser
JavaScript
13
star
12

node-binary-search

An addon to node.js that provides a binary search function that runs in native C++.
C++
11
star
13

awesome-clojure-spec

A catalog of interesting clojure.spec repos and gists
10
star
14

balanced-go

Balanced API Client for Go
Go
8
star
15

dependency-promise

Add the Deferrable Pattern to Your Dependency Graphs
JavaScript
5
star
16

data-structures-js

Data structures for Javascript
JavaScript
5
star
17

array-promise

Act on asynchronously loaded arrays via forEach, map, etc without the usual, messy callback interface.
JavaScript
2
star
18

bnoguchi.github.com

Github User Page
2
star
19

private-slack-welcome

Slack RTM client that sends a Direct Message welcome message when a new team member joins
Go
1
star