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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.fayupable.snowflake.port.IdGenerator
nextIds
-
Constructor Details
-
SnowflakeIdGenerator
-
SnowflakeIdGenerator
-
-
Method Details
-
nextId
public long nextId()- Specified by:
nextIdin interfaceIdGenerator
-