1
1
2
- uid-generator-spring-boot-starter
2
+ uid-reactive- generator-spring
3
3
==========================
4
4
5
5
[ 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
14
14
* Supported Reactive Programming,Return a ` Mono<Long> ` ,
15
15
* In CachedUidGenerator:When consumption rate is higher than refill rate,Notify subscribers in a non-blocking manner after waiting for the fill to complete.
16
16
* 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
18
19
19
20
20
21
## Principle and performance
@@ -23,150 +24,74 @@ Refer [Snowflake](https://github.com/twitter/snowflake) and [UidGenerator](https
23
24
24
25
## Usage
25
26
26
- ### Maven
27
+ ### For Spring boot autoconfig
27
28
28
- #### for Spring boot autoconfig
29
-
30
- Current version is:1.0.5
29
+ #### Worker node ID by Spring Discover service(not need databases)
31
30
32
31
``` 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 -->
45
32
<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 >
49
36
</dependency >
50
37
38
+ ...
39
+ ```
40
+ NOTE: only test on Consul
51
41
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
72
43
73
- <!-- r2dbc -->
44
+ ``` xml
74
45
<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 >
78
49
</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 >
80
74
```
81
75
82
76
83
- ### Databases(optional)
84
- Table WORKER_NODE scrip:
77
+ * Databases scrip:
85
78
``` sql
86
79
DROP TABLE IF EXISTS WORKER_NODE;
87
80
CREATE TABLE WORKER_NODE
88
81
(
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)
97
90
) COMMENT= ' DB WorkerID Assigner for UID Generator' ,ENGINE = INNODB;
98
91
```
99
92
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
158
93
159
- ` ` ` yml
160
94
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
- ```
170
95
171
96
172
97
#### CachedUidGenerator rejected handler(optional)
0 commit comments