How to implement GUID With Python
GUID?
Unique ID
When you need Unique ID?
User ID?
User ID? Service ID?
User ID? Service ID?
Event ID?
Example
A Long Long Time Ago
Mac Address?
Device ID?
So, we need Unique ID!!!
UUID
Universally Unique ID
Universally Unique ID
RFC 4122
550e8400-e20b-41d4-a716-446655440000
16 Octet (128bit)
SHA-1(MAC+Time)
BUT …
BUT … BUT …
BUT … BUT … BUT …
UUID is not good For Some Services
Why?
Too Big
Can’t order by Time
How to get these attributes!!
Research Just Google it.
MongoDB
Twitter SnowFlake
MongoDB
12 Bytes BSON Object
MongoDB
64 bits
Logical Shard Physical Shard
Slowflake
64 bits
Snowflake
Snowflake
Zookeeper
Python-Guoid
import guoid guid = guoid.SnowFlake(datacenter_id, worker_id) guid.next()
Python-Guoid
https://github.com/charsyam/python-guoid
Python-Guoid
Not service Just Library
Python-Guoid
How to get Datacenter_id
Worker_id
Thank you!
Recommended