Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/youkale/snowflake-go
Twitter雪花算法ID生成器 支持Redis,HTTP调用
https://github.com/youkale/snowflake-go
grpc http id-generator redis snowflake
Last synced: 22 days ago
JSON representation
Twitter雪花算法ID生成器 支持Redis,HTTP调用
- Host: GitHub
- URL: https://github.com/youkale/snowflake-go
- Owner: youkale
- License: apache-2.0
- Created: 2018-08-11T07:36:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-11T07:41:14.000Z (over 6 years ago)
- Last Synced: 2024-10-08T18:42:22.811Z (about 1 month ago)
- Topics: grpc, http, id-generator, redis, snowflake
- Language: Go
- Size: 35.2 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Snowflake-go
-----基于 [bwmarrin/snowflake](https://github.com/bwmarrin/snowflake.git) 实现```grpc```,```http```,```redis```API。
使用场景: 你已经厌倦了数据库自增ID,想换一个专门的ID生成器,那么你可以试试这个.
Twitter雪花算法
```
+--------------------------------------------------------------------------+
| 1 Bit Unused | 41 Bit Timestamp | 10 Bit NodeID | 12 Bit Sequence ID |
+--------------------------------------------------------------------------+
```支持协议
----#### redis
```
协议
> *2\r\n$4\r\nsfid\r\n$1\r\n5\r\n
< +{"id":"1023510546613293056","base32":"hpb7pppcywyy","base58":"3nNeLuv1t79"}redis-cli
127.0.0.1:8199> sfid 5
{"id":"1023510546613293056","base32":"hpb7pppcywyy","base58":"3nNeLuv1t79"}
```#### http
```
request: GET http://127.0.0.1:8199/sf-gen?node_id=2
ok response: Content-Type: application/json
{
"status": 0,
"message": "ok",
"data": {
"id": "1023526277203632128",
"base32": "hpnmz8ioyeyy",
"base58": "3nNmTH2pKnJ"
}
}
error response: Content-Type: application/json
{
"status": -1,
"message": "error node_id"
}```
#### grpc
你问我支持不支持,我当然是支持的。
(暂时没有编译客户端.)License
-----Apache License 2.0