Get Machine Identifier

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.

1 Like

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

3 Likes

Thanks!

Just for the record, from your link, we can get machine id from {:ok, hostname} = :inet.gethostname.

1 Like

@dc0d - :inet.gethostname is not always returning the host name. I’m experiencing often situations where the above returns just an empty string.

1 Like