A local implementation of Snowflake generation in Java.
Licensed under the Apache 2.0 License.
This library is now discontinued, use Nanoflakes Java implementation now.
Using in Gradle:
repositories {
jcenter()
}
dependencies {
compile 'net.notjustanna.libs:snowflake-local:LATEST' // replace LATEST with the version above
}Using in Maven:
<repositories>
<repository>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.notjustanna.libs</groupId>
<artifactId>snowflake-local</artifactId>
<version>LATEST</version> <!-- replace LATEST with the version above -->
</dependency>
</dependencies>Use LocalGenerator or LocalGeneratorBuilder to create the local generators.
SnowflakeGenerator generator = new LocalGeneratorBuilder()
.epoch(1420070400000L)
.build();Then use the SnowflakeGenerator to generate IDs.
long id = generator.getDatacenter(3L).getWorker(0L).generate();