Skip to content
Bluetape4k docs1.11

Distributed ID Generators

Latest stable Based on Bluetape4k release 1.11.0

Generates unique IDs in distributed environments using a variety of algorithms. UUID (V1–V7), ULID, KSUID, Snowflake, Flake, and Hashids are exposed through a unified IdGenerator interface. This manual connects that purpose to the current build, source entry points, tests, configuration resources, and lifecycle evidence instead of duplicating the README feature list.

Use bluetape4k-idgenerators when the application needs input contracts, value semantics, algorithmic cost, and deterministic output. Start with the source entry points below and confirm that their ownership and failure contracts match the calling component. Prefer a smaller standard-library or already-adopted module when it satisfies the same contract without another runtime boundary.

dependencies {
implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<version>"))
implementation("io.github.bluetape4k:bluetape4k-idgenerators")
}

Gradle project path: :bluetape4k-idgenerators. Source directory: utils/idgenerators.

The first source-level concepts to inspect are IdGenerator, LongIdGenerator, MachineIdSupport, Flake, Hashids, HashidsSupport, BitInputStream, and BitOutputStream. File names are navigation anchors; read each declaration and its tests before treating it as a public contract.

Add the coordinate above, refresh Gradle, and start from the smallest entry point that owns the required task. Open IdGenerator first; it is a concrete source entry point for the module.

Entry pointWhat to verify
IdGeneratorInspect this declaration’s constructors, functions, and ownership contract.
LongIdGeneratorInspect this declaration’s constructors, functions, and ownership contract.
MachineIdSupportInspect this declaration’s constructors, functions, and ownership contract.
FlakeInspect this declaration’s constructors, functions, and ownership contract.
HashidsInspect this declaration’s constructors, functions, and ownership contract.
HashidsSupportInspect this declaration’s constructors, functions, and ownership contract.
BitInputStreamInspect this declaration’s constructors, functions, and ownership contract.
BitOutputStreamInspect this declaration’s constructors, functions, and ownership contract.
BytesBase62Inspect this declaration’s constructors, functions, and ownership contract.
KsuidInspect this declaration’s constructors, functions, and ownership contract.

The README evidence is organized around Algorithm Selection Guide, Architecture, All Algorithms at a Glance, Class Diagram, Snowflake Bit Layout, Supported Algorithms, Usage Examples, Snowflake (Twitter-style), UUID (Unified API), and ULID (Universally Unique Lexicographically Sortable Identifier). Use those topics as a navigation map, then confirm behavior in source and tests. Keep adoption narrow and connect owned resources to the caller lifecycle.

The current build declares these integration edges:

api(project(":bluetape4k-core"))
api(libs.java.uuid.generator) // https://github.com/cowtowncoder/java-uuid-generator
implementation(project(":bluetape4k-coroutines"))
implementation(libs.kotlinx.coroutines.core)

Treat compileOnly edges as caller-provided capabilities and verify runtime availability before using their APIs.

No module-level configuration resource was found under src/main/resources. Configuration is supplied through constructors, builders, function arguments, or the integrating framework; confirm defaults in source.

Failure semantics are defined by the linked entry points and tests, not inferred from the artifact name. Keep cancellation and timeout signals intact, close owned resources, and translate backend exceptions only at a boundary that can add a stable domain contract. Use the test anchors below to verify the exact behavior before adding retries or fallbacks.

Measure hot paths, bound input sizes, and monitor failures at the application boundary that calls the utility. Keep capacity, timeout, retry, and shutdown settings next to the component that owns the resource; avoid process-wide defaults that hide which caller accepted the trade-off.

Run the module test task:

Terminal window
./gradlew :bluetape4k-idgenerators:test --no-configuration-cache

Representative test anchors:

No dedicated workshop path is registered in the manual manifest. Use the module README and the representative tests above as runnable evidence.

This page documents the repository state represented by the linked source and tests. It does not turn optional backends into application defaults or claim performance without a benchmark artifact. Re-check compatibility and lifecycle notes when the module version changes.

These diagrams are loaded directly from README assets published with the 1.11.0 release and pinned to its immutable commit. They describe this manual’s released structure and runtime flows, not later Snapshot changes. Select a preview to open the SVG at the same release commit.

All Algorithms at a Glance diagram

Release README: utils/idgenerators/README.md

ID Generators Class Structure diagram

Release README: utils/idgenerators/README.md

Snowflake Bit Layout diagram

Release README: utils/idgenerators/README.md

ULID (Universally Unique Lexicographically Sortable Identif. diagram

Section titled “ULID (Universally Unique Lexicographically Sortable Identif. diagram”

ULID (Universally Unique Lexicographically Sortable Identif. diagram

Release README: utils/idgenerators/README.md

ULID (Universally Unique Lexicographically Sortable Identif. diagram

Section titled “ULID (Universally Unique Lexicographically Sortable Identif. diagram”

ULID (Universally Unique Lexicographically Sortable Identif. diagram

Release README: utils/idgenerators/README.md

KSUID Layout diagram

Release README: utils/idgenerators/README.md

Flake Layout diagram

Release README: utils/idgenerators/README.md