在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:tinyid开源软件地址:https://gitee.com/didiopensource/tinyid开源软件介绍:TinyidTinyid 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 startedClone codegit clone https://github.com/didi/tinyid.git Create tablecd tinyid/tinyid-server/ && create table with db.sql (mysql) Config dbcd tinyid-server/src/main/resources/offline 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-servercd tinyid-server/sh build.sh offlinejava -jar output/tinyid-server-xxx.jar REST APInextId: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 classpathtinyid_client.properties: tinyid.server=localhost:9999tinyid.token=0f673adf80504e2eaa552f5d791b644c#(tinyid.server=localhost:9999/gateway,ip2:port2/prefix,...) Java CodeLong id = TinyId.nextId("test");List<Long> ids = TinyId.nextId("test", 10); CommunicationContributingWelcome to contribute by creating issues or sending pull requests. See Contributing Guide for guidelines. LicenseTinyid is licensed under the Apache License 2.0. See the LICENSE file. NoteThis is not an official Didi product (experimental or otherwise), it is just code that happens to be owned by Didi. |
请发表评论