Documentation
¶
Overview ¶
Package idgen provides a lock-free snowflake ID generator for stream writes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator produces unique 64-bit snowflake IDs using a lock-free CAS loop. Bit layout: [1-bit sign=0] [46-bit ms timestamp] [7-bit node ID] [10-bit sequence]. The internal state packs lastTime and sequence into a single uint64: state = (lastTime << sequenceBits) | sequence.
func NewGenerator ¶
NewGenerator creates a Generator whose 7-bit node component is derived by hashing the given nodeID string.
Click to show internal directories.
Click to hide internal directories.