Package com.fayupable.snowflake
Class SnowflakeIdGenerator
java.lang.Object
com.fayupable.snowflake.SnowflakeIdGenerator
- All Implemented Interfaces:
IdGenerator
Thread-safe Snowflake id generator.
Encodes timestamp and sequence into a single AtomicLong state, updated via CAS,
avoiding locks while guaranteeing monotonic, collision-free ids per node.
-
Constructor Summary
ConstructorsConstructorDescriptionSnowflakeIdGenerator(SnowflakeConfig config, ClockSource clock) SnowflakeIdGenerator(SnowflakeConfig config, ClockSource clock, SnowflakeMetrics metrics) -
Method Summary
-
Constructor Details
-
SnowflakeIdGenerator
-
SnowflakeIdGenerator
-
-
Method Details
-
nextId
public long nextId()- Specified by:
nextIdin interfaceIdGenerator
-