A distributed id generation solution based on zookeeper and Twitter Snowflake
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
spring-boot-starter-id-generator-zookeeper
.gitignore
LICENSE
README.md
pom.xml

README.md

dependency

  • zookeeper 3.4.10

Usage

Install or deploy to private Repository

  • mvn clean install or mvn clean deploy

id generator

  • add dependency to maven
<dependency>
    <groupId>io.github.goudai</groupId>
    <artifactId>spring-boot-starter-id-generator-zookeeper</artifactId>
    <version>1.0.2</version>
</dependency>
  • using on spring boo
# application.yml
goudai:
  id:
    generator:
      zookeeper:
        zookeeper-servers: ${ZOO_SERVERS:localhost:2181}
public class XxxController {

    @Autowired
    IdGenerator idGenerator;

    @GetMapping("idString")
    public String idString() {
        return idGenerator.nextIdAsString();
    }

    @GetMapping("idLong")
    public Long idLong() {
        return idGenerator.nextIdAsLong();
    }
}