11
2- uid-generator-spring-boot-starter
2+ uid-reactive- generator-spring
33==========================
44
55[ In Chinese 中文版] ( https://github.com/cooperlyt/uid-generator-spring-boot/blob/master/README.cn.md )
@@ -14,7 +14,8 @@ Based on [Snowflake](https://github.com/twitter/snowflake),[UidGenerator](http
1414* Supported Reactive Programming,Return a ` Mono<Long> ` ,
1515 * In CachedUidGenerator:When consumption rate is higher than refill rate,Notify subscribers in a non-blocking manner after waiting for the fill to complete.
1616 * In DefaultUidGenerator and not allow use future time state:Notify subscribers in a non-blocking way after the current time ID is exhausted and waits for the next second.
17- * Supported mybatis jdbc, mybatis r2bc , jap jdbc , jap r2dbc
17+ * Supported get worker node id from db by mybatis jdbc, mybatis r2bc , jap jdbc , jap r2dbc
18+ * Supported get worker node id from Spring Discovery service
1819
1920
2021## Principle and performance
@@ -23,150 +24,74 @@ Refer [Snowflake](https://github.com/twitter/snowflake) and [UidGenerator](https
2324
2425## Usage
2526
26- ### Maven
27+ ### For Spring boot autoconfig
2728
28- #### for Spring boot autoconfig
29-
30- Current version is:1.0.5
29+ #### Worker node ID by Spring Discover service(not need databases)
3130
3231``` xml
33-
34- <!-- Choose one and only on -->
35-
36-
37- <!-- mybatis jdbc -->
38- <dependency >
39- <groupId >cooperlyt.github.io</groupId >
40- <artifactId >uid-generator-mybatis-jdbc-spring-boot-starter</artifactId >
41- <version >${uid.version}</version >
42- </dependency >
43-
44- <!-- mybatis r2dbc -->
4532<dependency >
46- <groupId >cooperlyt .github.io </groupId >
47- <artifactId >uid-generator-mybatis-r2dbc- spring-boot -starter</artifactId >
48- <version >${uid.version} </version >
33+ <groupId >io .github.cooperlyt </groupId >
34+ <artifactId >uid-reactive- generator-spring-cloud -starter-discovery </artifactId >
35+ <version >1.1.1 </version >
4936</dependency >
5037
38+ ...
39+ ```
40+ NOTE: only test on Consul
5141
52- <!-- jpa jdbc -->
53- <dependency >
54- <groupId >cooperlyt.github.io</groupId >
55- <artifactId >uid-generator-jap-jdbc-spring-boot-starter</artifactId >
56- <version >${uid.version}</version >
57- </dependency >
58-
59- <!-- jpa r2dbc -->
60- <dependency >
61- <groupId >cooperlyt.github.io</groupId >
62- <artifactId >uid-generator-jpa-r2dbc-spring-boot-starter</artifactId >
63- <version >${uid.version}</version >
64- </dependency >
65-
66- <!-- example for mariadb database driver-->
67- <!-- jdbc -->
68- <dependency >
69- <groupId >org.mariadb.jdbc</groupId >
70- <artifactId >mariadb-java-client</artifactId >
71- </dependency >
42+ #### Worker node ID by DB
7243
73- <!-- r2dbc -->
44+ ``` xml
7445<dependency >
75- <groupId >org.mariadb </groupId >
76- <artifactId >r2dbc-mariadb </artifactId >
77- <version >1.1.3 </version >
46+ <groupId >io.github.cooperlyt </groupId >
47+ <artifactId >uid-reactive-generator-db-spring-boot-starter </artifactId >
48+ <version >1.1.1 </version >
7849</dependency >
79-
50+ ```
51+ * Mybatis JDBC:
52+ ``` xml
53+ <dependency >
54+ <groupId >org.mybatis.spring.boot</groupId >
55+ <artifactId >mybatis-spring-boot-starter</artifactId >
56+ <version >2.3.0</version >
57+ </dependency >
58+ ```
59+ * Mybatis R2DBC
60+ Refer [ reactive-mybatis-support] ( https://github.com/chenggangpro/reactive-mybatis-support )
61+ * JPA JDBC:
62+ ``` xml
63+ <dependency >
64+ <groupId >org.springframework.boot</groupId >
65+ <artifactId >spring-boot-starter-data-jpa</artifactId >
66+ </dependency >
67+ ```
68+ * JPA R2DBC
69+ ``` xml
70+ <dependency >
71+ <groupId >org.springframework.boot</groupId >
72+ <artifactId >spring-boot-starter-data-r2dbc</artifactId >
73+ </dependency >
8074```
8175
8276
83- ### Databases(optional)
84- Table WORKER_NODE scrip:
77+ * Databases scrip:
8578``` sql
8679DROP TABLE IF EXISTS WORKER_NODE;
8780CREATE TABLE WORKER_NODE
8881(
89- ID BIGINT NOT NULL AUTO_INCREMENT COMMENT ' auto increment id' ,
90- HOST_NAME VARCHAR (64 ) NOT NULL COMMENT ' host name' ,
91- PORT VARCHAR (64 ) NOT NULL COMMENT ' port' ,
92- TYPE INT NOT NULL COMMENT ' node type: CONTAINER(1), ACTUAL(2), FAKE(3)' ,
93- LAUNCH_DATE DATE NOT NULL COMMENT ' launch date' ,
94- MODIFIED TIMESTAMP NOT NULL COMMENT ' modified time' ,
95- CREATED TIMESTAMP NOT NULL COMMENT ' created time' ,
96- PRIMARY KEY (ID)
82+ ID BIGINT NOT NULL AUTO_INCREMENT COMMENT ' auto increment id' ,
83+ HOST VARCHAR (64 ) NOT NULL COMMENT ' host name' ,
84+ PORT VARCHAR (64 ) NOT NULL COMMENT ' port' ,
85+ TYPE INT NOT NULL COMMENT ' node type: CONTAINER(1), ACTUAL(2), FAKE(3)' ,
86+ LAUNCH DATE NOT NULL COMMENT ' launch date' ,
87+ MODIFIED TIMESTAMP NOT NULL COMMENT ' modified time' ,
88+ CREATED TIMESTAMP NOT NULL COMMENT ' created time' ,
89+ PRIMARY KEY (ID)
9790) COMMENT= ' DB WorkerID Assigner for UID Generator' ,ENGINE = INNODB;
9891```
9992
100- ### spring boot configure
101-
102- Example for mariadb
103-
104- #### mybatis jdbc
105-
106- ``` yml
107- mybatis :
108- configuration :
109- default-fetch-size : 100
110- default-statement-timeout : 30
111- map-underscore-to-camel-case : true
112- spring :
113- datasource :
114- driver-class-name : org.mariadb.jdbc.Driver
115- url : jdbc:mariadb://127.0.0.1:3306/database?
116- username : root
117- password : ****
118- ` ` `
119-
120- #### mybatis r2dbc
121- refer [reactive-mybatis-support](https://github.com/chenggangpro/reactive-mybatis-support)
122- ` ` ` yml
123-
124- r2dbc :
125- mybatis :
126- mapper-locations : classpath:mapper/*.xml
127- map-underscore-to-camel-case : true
128- spring :
129- r2dbc :
130- mybatis :
131- r2dbc-url : r2dbc:mariadb://127.0.0.1:3306/database
132- username : root
133- password : ****
134- pool :
135- max-idle-time : PT3M
136- validation-query : SELECT 1 FROM DUAL
137- initial-size : 1
138- max-size : 3
139- acquire-retry : 3
140- validation-depth : REMOTE
141- max-create-connection-time : PT30S
142- ` ` `
143-
144- #### jpa jdbc
145-
146- ` ` ` yml
147- spring :
148- jpa :
149- show-sql : true
150- datasource :
151- driver-class-name : org.mariadb.jdbc.Driver
152- url : jdbc:mariadb://127.0.0.1:3306/corp?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&allowMultiQueries=true
153- username : root
154- password : ****
155- ` ` `
156-
157- #### jpa r2dbc
15893
159- ` ` ` yml
16094
161- spring :
162- r2dbc :
163- url : r2dbc:mariadb://127.0.0.1:3306/corp?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false
164- username : root
165- password : ****
166- # pool:
167- # initial-size: 11
168-
169- ```
17095
17196
17297#### CachedUidGenerator rejected handler(optional)
0 commit comments