bwmarrin / snowflake

A simple to use Go (golang) package to generate or parse Twitter snowflake IDs
BSD 2-Clause "Simplified" License
2.98k stars 371 forks source link

Add convenience generator to creates nodes by hostname #3

Closed connor4312 closed 8 years ago

connor4312 commented 8 years ago

Adds a quick NewNodeByHostname() function which assigns an ID based off a hash of the hostname. Not 100% super duper safe but good for smaller clusters (< 38 nodes, at which point the chance of two nodes having the same ID exceeds 50%) or clusters where consensus is not immediately available.

bwmarrin commented 8 years ago

I'm a bit timid to add this knowing it has a reasonable chance of providing duplicate node IDs and in that case it would cause this package to be unable to guarantee that it's generating unique IDs.

connor4312 commented 8 years ago

Fair enough 😄