rendezvous-hash v0.3.1

Rendezvous hashing for crystal

rendezvous-hash

Build Status

Rendezvous hashing for crystal that utilises the murmur3 hashing algorithm.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      rendezvous-hash:
        github: caspiano/rendezvous-hash
    
  2. Run shards install

Usage


require "rendezvous-hash"

hash = RendezvousHash.new(nodes: ["node1", "node2", "node3"])

hash.find("device1")  # => "node3"

hash.remove("node3")  # => "node3"

hash.nodes            # => ["node1", "node2"]

hash.find("device1")  # => "node1"

hash.remove?("node3") # => nil

hash.add("node3")     # => ["node1", "node2", "node3"]

hash.find("device1")  # => "node3"

hash["device1"]  # => "node3"

Credit

Todo

  • Benchmarking
  • murmur3 seeding

Contributing

  1. Fork it
  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

Repository

rendezvous-hash

Owner
Statistic
  • 2
  • 1
  • 0
  • 2
  • 1
  • over 4 years ago
  • July 31, 2019
License

MIT License

Links
Synced at

Wed, 15 May 2024 16:03:58 GMT

Languages