Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/didi/tinyid
ID Generator id生成器 分布式id生成系统,简单易用、高性能、高可用的id生成系统
https://github.com/didi/tinyid
Last synced: 25 days ago
JSON representation
ID Generator id生成器 分布式id生成系统,简单易用、高性能、高可用的id生成系统
- Host: GitHub
- URL: https://github.com/didi/tinyid
- Owner: didi
- License: apache-2.0
- Created: 2018-09-26T06:34:57.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-06-21T00:47:59.000Z (over 2 years ago)
- Last Synced: 2024-09-27T02:47:13.526Z (about 1 month ago)
- Language: Java
- Homepage:
- Size: 299 KB
- Stars: 2,277
- Watchers: 75
- Forks: 580
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome - didi/tinyid - ID Generator id生成器 分布式id生成系统,简单易用、高性能、高可用的id生成系统 (Java)
README
## Tinyid
[![license](http://img.shields.io/badge/license-Apache2.0-brightgreen.svg?style=flat)](https://github.com/didi/tinyid/blob/master/LICENSE)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/didi/tinyid/pulls)Tinyid is a ID Generator Service. It provides a REST API and a java client for getting ids. Over 10 million QPS per single instance when using the java client.
Support jdk version 1.7+# Getting started
[中文wiki](https://github.com/didi/tinyid/wiki)
## Clone code
git clone https://github.com/didi/tinyid.git## Create table
cd tinyid/tinyid-server/ && create table with db.sql (mysql)## Config db
cd tinyid-server/src/main/resources/offline
vi application.properties
```properties
datasource.tinyid.names=primarydatasource.tinyid.primary.driver-class-name=com.mysql.jdbc.Driver
datasource.tinyid.primary.url=jdbc:mysql://ip:port/databaseName?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
datasource.tinyid.primary.username=root
datasource.tinyid.primary.password=123456
```
## Start tinyid-server
```xml
cd tinyid-server/
sh build.sh offline
java -jar output/tinyid-server-xxx.jar
```
## REST API
```properties
nextId:
curl 'http://localhost:9999/tinyid/id/nextId?bizType=test&token=0f673adf80504e2eaa552f5d791b644c'
response:{"data":[2],"code":200,"message":""}nextId Simple:
curl 'http://localhost:9999/tinyid/id/nextIdSimple?bizType=test&token=0f673adf80504e2eaa552f5d791b644c'
response: 3with batchSize:
curl 'http://localhost:9999/tinyid/id/nextIdSimple?bizType=test&token=0f673adf80504e2eaa552f5d791b644c&batchSize=10'
response: 4,5,6,7,8,9,10,11,12,13Get nextId like 1,3,5,7,9...
bizType=test_odd : delta is 2 and remainder is 1
curl 'http://localhost:9999/tinyid/id/nextIdSimple?bizType=test_odd&batchSize=10&token=0f673adf80504e2eaa552f5d791b644c'
response: 3,5,7,9,11,13,15,17,19,21
```
## Java client (Recommended)### Maven dependency
```xmlcom.xiaoju.uemc.tinyid
tinyid-client
${tinyid.version}```
### Create tinyid_client.properties in your classpath
tinyid_client.properties:
```properties
tinyid.server=localhost:9999
tinyid.token=0f673adf80504e2eaa552f5d791b644c#(tinyid.server=localhost:9999/gateway,ip2:port2/prefix,...)
```
### Java Code
```java
Long id = TinyId.nextId("test");
List ids = TinyId.nextId("test", 10);
```# Communication
# Contributing
Welcome to contribute by creating issues or sending pull requests. See [Contributing Guide](CONTRIBUTING.md) for guidelines.
# License
Tinyid is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file.
# Note
This is not an official Didi product (experimental or otherwise), it is just code that happens to be owned by Didi.