How to get the machine identifier?
I want to write an id generator based on this Go package, a MongoDB-like ObjectID which is unique and (relatively) sequential.
How to get the machine identifier?
I want to write an id generator based on this Go package, a MongoDB-like ObjectID which is unique and (relatively) sequential.
You can look into how the ObjectID generation is implemented in the mongodb package https://github.com/ericmj/mongodb/blob/master/lib/mongo/id_server.ex
Thanks!
Just for the record, from your link, we can get machine id from {:ok, hostname} = :inet.gethostname
.
@dc0d - :inet.gethostname
is not always returning the host name. I’m experiencing often situations where the above returns just an empty string.