sony / sonyflake

A distributed unique ID generator inspired by Twitter's Snowflake
MIT License
3.9k stars 304 forks source link

Hard coded IP address should be dynamic? #1

Closed dlsniper closed 9 years ago

dlsniper commented 9 years ago

Hi,

Thanks for open sourcing this. I've read the source code and it seems that here https://github.com/sony/sonyflake/blob/master/awsutil/awsutil.go#L16 the IP address / URL is hard coded and can't be changed by the user. Shouldn't this be part of some sort of parameter one initializes the package with?

I can work on a PR to do the following changes:

However this would be a breaking change and I'd like to know your thoughts on this one first.

YoshiyukiMineo commented 9 years ago

The AWS metadata API has the fixed IP address and URL. So it is hard coded. See http://docs.aws.amazon.com/en_us/AWSEC2/latest/UserGuide/ec2-instance-metadata.html

If you'd like to use a different kind of MachineID, you can set Settings.MachineID.

dlsniper commented 9 years ago

Makes sense. Thanks for the fast reply.