Package com.fayupable.snowflake.port
Interface IdGenerator
- All Known Implementing Classes:
SnowflakeIdGenerator
public interface IdGenerator
Input port for generating unique identifiers.
Implementations decide the algorithm (Snowflake, ULID, etc.).
-
Method Summary
-
Method Details
-
nextId
long nextId() -
nextIds
default long[] nextIds(int count) Generatescountids in one call. The default implementation simply callsnextId()in a loop; implementations that can do better under contention (e.g. advancing the internal sequence in a single CAS) may override this for a more efficient batch path.- Parameters:
count- how many ids to generate, must be positive- Returns:
- an array of
countids, in generation order
-