Seeds the TSID Creator node ID from a coordinated NodeId at application startup, so each replica of a horizontally scaled service generates collision-free TSIDs.
Add this dependency to your build.gradle:
dependencies {
implementation 'io.seqera:lib-util-tsid:1.0.0'
}TsidCreator reads its node ID from the tsidcreator.node system property at first use, via a lazily-initialised factory holder. TsidNodeConfigurer is an eager (@Context) Micronaut bean that sets the property during startup — well before the first TsidCreator call:
tsidcreator.nodeis set to the ordinal assigned by theNodeIdbeantsidcreator.node.countis set to theNodeIdcapacity, only when it differs from the TSID default node space (1024, i.e. 10 node bits)
No code changes are needed at TSID call sites — just having this library on the classpath wires the node ID.
A NodeId bean must be available, provided by lib-node-id-redis (pulled in transitively): Redis-backed ordinal assignment when a RedisActivator bean is present, in-memory fallback otherwise.
seqera:
node-id:
capacity: 1024 # Align with the TSID node-bit allocation (default: 1024 = 10 bits)./gradlew :lib-util-tsid:testApache 2.0