• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

tinyid: tinyid 是滴滴开发的 id 生成器 分布式id生成系统,简单易用、高性能、高可用 ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

tinyid

开源软件地址:

https://gitee.com/didiopensource/tinyid

开源软件介绍:

Tinyid

licensePRs Welcome

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

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

datasource.tinyid.names=primarydatasource.tinyid.primary.driver-class-name=com.mysql.jdbc.Driverdatasource.tinyid.primary.url=jdbc:mysql://ip:port/databaseName?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8datasource.tinyid.primary.username=rootdatasource.tinyid.primary.password=123456

Start tinyid-server

cd tinyid-server/sh build.sh offlinejava -jar output/tinyid-server-xxx.jar

REST API

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 1curl '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

<dependency>    <groupId>com.xiaoju.uemc.tinyid</groupId>    <artifactId>tinyid-client</artifactId>    <version>${tinyid.version}</version></dependency>

Create tinyid_client.properties in your classpath

tinyid_client.properties:

tinyid.server=localhost:9999tinyid.token=0f673adf80504e2eaa552f5d791b644c#(tinyid.server=localhost:9999/gateway,ip2:port2/prefix,...)

Java Code

Long id = TinyId.nextId("test");List<Long> ids = TinyId.nextId("test", 10);

Communication

Tinyid Community

Contributing

Welcome to contribute by creating issues or sending pull requests. See Contributing Guide for guidelines.

License

Tinyid is licensed under the Apache License 2.0. See the LICENSE file.

Note

This is not an official Didi product (experimental or otherwise), it is just code that happens to be owned by Didi.


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap