olegbespalov / luigi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Luigi

Lazada unique identifier generator

Luigi

Algorithm:

  1. NodeID = ((HostID << PIDLengthInBits) | PID) << counterLengthInBits

  2. Timestamp = Now() - ToTimestamp(20.02.2016, 14:23:57)

  3. 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!

About


Languages

Language:Go 76.9%Language:Makefile 23.1%