【文件属性】:
文件名称:idGenerator:使用golanggo的idGenerator
文件大小:8KB
文件格式:ZIP
更新时间:2021-02-24 11:41:09
Go
#ID产生器
用go实现的id生成器,支持每秒qps:131072,超过需要等待下一秒
依赖
mysql(或zk,redis等)
需要使用mysql来保证多台机器获取到的workId不同当然,如果是单点,那随意设置workId
使用介绍
初始化程序
mysql的建表语句
config.json
在connect_info上添上连接mysql的信息
用法
ring := NewRing ( 1 << 17 , GetWorkId ( "config.json" ))
id , err := ring . Take ()
这里GetWorkId重置使用的是mysql,你也可以使用zk等自定义的workId,以便于
【文件预览】:
idGenerator-master
----.gitignore(6B)
----go.mod(219B)
----generator.go(85B)
----id_struct.go(749B)
----id_struct_test.go(587B)
----go.sum(2KB)
----ring.go(4KB)
----ring_test.go(449B)
----README.md(561B)
----init.sql(513B)
----padding_executor.go(866B)
----config.json(49B)
----default_workId.go(1KB)