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

npm != github #10

Closed eveiga closed 11 years ago

eveiga commented 11 years ago

Hi 3rd-Eden,

First of all, thanks a lot for the module!

The version that is being installed by npm (0.0.7) doesn't match with the code here on github! For example, the method get doesn't exist (just the getNode).

See it for yourself: https://registry.npmjs.org/hashring/-/hashring-0.0.7.tgz

Could you please fix it?

Thanks in advance :)

Best regards

3rd-Eden commented 11 years ago

Hey,

The master branch of this repository is used for the development of the module so it will contain bits and pieces that are not yet released in NPM. This is also the reason why NPM has it's own README file now.

I do usually tag releases so they also have stable documentation, but it seems that I have forgotten that as well for the 0.0.7 release. So my apologies for that. As 0.0.7 didn't involve any API changes you can use the documentation from 0.0.6 as guide for now; https://github.com/3rd-Eden/node-hashring/tree/v0.0.6

I'll be releasing the master branch this week as 0.0.8 as the new API's are backwards compatible. They are just easier to write and understand. You can see the API differences in this commit: https://github.com/3rd-Eden/node-hashring/commit/2ea455b2c3bbcbb36928ab722d21b29874d3ad88

Again my apologies for the confusion!

eveiga commented 11 years ago

Wow, thanks for the fast reply :)

eveiga commented 11 years ago

Do you have any idea why your crc32 algorithm is giving differente value from the php crc32 one?

eveiga commented 11 years ago

Ok, looks like this is an old question :sa:

http://erlycoder.com/121/javascript-crc32-that-mathes-php-crc32-and-works-well-with-unicode

eveiga commented 11 years ago

Hey 3rd-Eden.

I think I found the problem. Apparently it's an old "issue" javascript crc32 implementations Vs php crc32 native function, returning differente results.

I've done a few tests and the only way I could get the same values was using this module: https://github.com/brianloveswords/buffer-crc32

Here you can see some comparisons: https://gist.github.com/piscis/4124412

I've had to remove the conversion to a long that you make, using only the returning value of crc32.unsigned(str).

Do you have any interest in supporting this on your module? Maybe by injecting the function on the hashring constructor (like your doing with the crypto functions, as a second parameter).

Best regards!

3rd-Eden commented 11 years ago

I wonder how much performance overhead the buffer-crc32 gives compared to the current solution. If's equal or faster i'm more than happy to even use it as the default version.

But accepting a custom hashing function in the constructor is always a great idea.

3rd-Eden commented 11 years ago

@eveiga released 0.0.8, which has the new API. Also you can set a custom hash function by supplying a function as algorithm