Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IntToBytes ¶
func RemoveUnusedBytes ¶
Types ¶
type Worker ¶
type Worker struct { ID int64 // 0 - 2 ^ IDBits IDBits uint64 IDShift uint64 Sequence int64 // 0 - 2 ^ SequenceBits SequenceBits uint64 LastTimeStamp int64 TimeStampBits uint64 TimeStampShift uint64 Frequency time.Duration TotalBits uint64 CustomEpoch int64 // contains filtered or unexported fields }
func NewWorker10 ¶
NewWorker10 will generate up to 4096000 unique ids/second for 69 years NewWorker10 will return nil if the ID is greater than 63 or less than 0
func NewWorker7 ¶
func NewWorker7() *Worker
NewWorker7 will generate up to 1024 unique ids/second for 68 years NewWorker7 is the only worker of its size with this configuration
func NewWorker8 ¶
func NewWorker8() *Worker
NewWorker8 will generate up to 81920 unique ids/second for 54 years NewWorker8 is the only worker of it's size with this configuration
func NewWorker9 ¶
NewWorker9 will generate up to 819200 unique ids/second for 87 years NewWorker9 will return nil if the ID is greater than 3 or less than 0
func (*Worker) UnsafeNextID ¶
UnsafeNextID is faster than NextID, but must be called within only one goroutine, otherwise ID uniqueness is not guaranteed.