Skip to content
/ gleafd Public

基于Go的分布式ID生成服务 - 参考美团Leaf实现

License

Notifications You must be signed in to change notification settings

derry6/gleafd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gleafd

基于Go的分布式ID生成服务, 具体设计来自于leaf美团分布式ID生成服务,参考美团点评开源的Java实现Leaf

基本API

count 参数可以批量获取ID

  1. Segment
/api/v1/segments/:biztag?count=1
  1. Snowflake
/api/v1/snowflakes/:biztag?count=1
  1. 健康检查
/api/v1/health

测试步骤

启动MySQL服务

docker run -d \
    --name gleafd_mysql \
    -p 5506:3306 \
    -e MYSQL_ROOT_PASSWORD=123456 \
    -e MYSQL_DATABASE=gleafd \
    -e MYSQL_USER=gleafd\
    -e MYSQL_PASSWORD=123456 \
    mysql:8.0.15

启动redis服务

docker run -d \
    --name gleafd_redis \
    -p 8379:6379 \
    redis:5.0.3-alpine

启动gleafd

git clone https://github.com/derry6/gleafd

cd gleafd/cmd/gleafd/
go run main.go

测试

可以使用curl等http工具测试。压力测试使用ab或者wrk等测试。

// segment
curl http://localhost:9060/api/v1/segments/example?count=1

// snowflake
curl http://localhost:9060/api/v1/snowflakes/example?count=1

Releases

No releases published

Packages

No packages published

Languages