Algorithm:
-
NodeID = ((HostID << PIDLengthInBits) | PID) << counterLengthInBits
-
Timestamp = Now() - ToTimestamp(20.02.2016, 14:23:57)
-
UniqueID = Timestamp | NodeID | Counter
Counter - increment atomic counter less than predefined defaultSequenceBits const
Luigi provides 3 basic methods for IDs generate:
- Generate() - single value
- GenerateSlice(n) - slice of UIDs with n values
- FillChannelFillChannel(ch chan<- *big.Int) chan error - continuously fill ch channel with UIDs
Luigi can generate UIDs of 3 types: uint64(supports millisecond timestamp), string and BigInt(supports nanosecond timestamp)
Luigi loves you!