Skip to content

A distributed id generation solution based on zookeeper and Twitter Snowflake

License

Notifications You must be signed in to change notification settings

goudai/spring-boot-starter-id-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 boot
# 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();
    }
}

About

A distributed id generation solution based on zookeeper and Twitter Snowflake

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages