3rd-Eden / node-hashring

hashring is a consistent hashing algorithm for Node.js that is compatible with libketama and python's hash_ring package
MIT License
350 stars 61 forks source link

node-hashring into the browser #14

Closed abernier closed 10 years ago

abernier commented 10 years ago

Hey,

When I try to browserify hashring, I get the following error:

browserify -r hashring
Error: Cannot find module './build/Release/hashvalue'

Have you ever tested using node-hashring on client-side through browserify? Could node-hashring be run within browser?

Thanks for sharing your knowledges about this.

3rd-Eden commented 10 years ago

Hey,

Hashrings can't run in browsers they require support for 64bit bitshifing and JavaScript only supports 32bit bitshifting. So in order to overcome this, I had a make a C++ addon which does the bitshifting operation. But this means that the current version cannot operate under browserify.

You could however use an older version of hashring which doesn't depend on the C++ fix that I added. But this would mean that your hashing is broken and inconsistent.

abernier commented 10 years ago

Thanks for your quick reply @3rd-Eden !

Apart from an older version (with which hashing would be "broken and inconsistent"), would you ever know an alternative hashing library that can do the job in browser?

Actually I'm using node-hashring within a view helper in order to choose a CDN host for a given asset. I just need to share that logic between server and browser.

Thank you