Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

tobyapi/hash_ring

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

hash_ring

The Consistent Hash Ring is a useful data structure when you operate the distributed servers. This library is implementation of Consistent Hash Ring based on the excellent Elixir hash ring lib.

Installation

Add this to your application's shard.yml:

dependencies:
  hash_ring:
    github: TobiasGSmollett/hash_ring

Usage

require "hash_ring"

# Register 3 servers
hash_ring = HashRing::HashRing.new(["one", "two", "three"])

# Every user is assigned a server by consistent hash ring.
hash_ring.get("user1") # => "three"
hash_ring.get("user2") # => "three"
hash_ring.get("user3") # => "one"
hash_ring.get("user4") # => "two"

# Removes the "two" server
hash_ring.remove("two")

# Exists two servers which are "one" and "three".
hash_ring.get("user1") # => "three"
hash_ring.get("user2") # => "three"
hash_ring.get("user3") # => "one"
hash_ring.get("user4") # => "three"

Contributing

  1. Fork it ( https://github.com/TobiasGSmollett/hash_ring/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • tobias TobiasGSmollett - creator, maintainer

About

Implementation of Consistent Hash Ring for Crystal

Resources

License

Stars

11 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.