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

    Modifier and Type
    Method
    Description
    long
     
    default long[]
    nextIds(int count)
    Generates count ids in one call.
  • Method Details

    • nextId

      long nextId()
    • nextIds

      default long[] nextIds(int count)
      Generates count ids in one call. The default implementation simply calls nextId() 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 count ids, in generation order