12
12
package io .vertx .mysqlclient ;
13
13
14
14
import io .vertx .codegen .annotations .Fluent ;
15
+ import io .vertx .codegen .annotations .GenIgnore ;
15
16
import io .vertx .codegen .annotations .VertxGen ;
16
17
import io .vertx .core .Context ;
17
18
import io .vertx .core .Future ;
24
25
import io .vertx .sqlclient .SqlClient ;
25
26
import io .vertx .sqlclient .SqlConnection ;
26
27
27
- import java .util .Collections ;
28
28
import java .util .List ;
29
29
import java .util .function .Function ;
30
+ import java .util .function .Supplier ;
30
31
31
32
import static io .vertx .mysqlclient .MySQLConnectOptions .fromUri ;
32
33
@@ -79,7 +80,7 @@ static MySQLPool pool(MySQLConnectOptions database, PoolOptions options) {
79
80
* Like {@link #pool(MySQLConnectOptions, PoolOptions)} with a specific {@link Vertx} instance.
80
81
*/
81
82
static MySQLPool pool (Vertx vertx , MySQLConnectOptions database , PoolOptions options ) {
82
- return pool (vertx , Collections . singletonList ( database ) , options );
83
+ return pool (vertx , () -> database , options );
83
84
}
84
85
85
86
/**
@@ -101,7 +102,26 @@ static MySQLPool pool(Vertx vertx, List<MySQLConnectOptions> databases, PoolOpti
101
102
return (MySQLPool ) MySQLDriver .INSTANCE .createPool (vertx , databases , options );
102
103
}
103
104
105
+ /**
106
+ * Create a connection pool to the MySQL {@code databases}. The supplier is called
107
+ * to provide the options when a new connection is created by the pool.
108
+ *
109
+ * @param databases the server supplier
110
+ * @param options the options for creating the pool
111
+ * @return the connection pool
112
+ */
113
+ @ GenIgnore
114
+ static MySQLPool pool (Supplier <MySQLConnectOptions > databases , PoolOptions options ) {
115
+ return pool (null , databases , options );
116
+ }
104
117
118
+ /**
119
+ * Like {@link #pool(Supplier, PoolOptions)} with a specific {@link Vertx} instance.
120
+ */
121
+ @ GenIgnore
122
+ static MySQLPool pool (Vertx vertx , Supplier <MySQLConnectOptions > databases , PoolOptions options ) {
123
+ return (MySQLPool ) MySQLDriver .INSTANCE .createPool (vertx , databases , options );
124
+ }
105
125
/**
106
126
* Like {@link #client(String, PoolOptions)} with a default {@code poolOptions}.
107
127
*/
@@ -137,14 +157,14 @@ static SqlClient client(Vertx vertx, String connectionUri, PoolOptions poolOptio
137
157
* @return the client
138
158
*/
139
159
static SqlClient client (MySQLConnectOptions connectOptions , PoolOptions poolOptions ) {
140
- return client (null , Collections . singletonList ( connectOptions ) , poolOptions );
160
+ return client (null , () -> connectOptions , poolOptions );
141
161
}
142
162
143
163
/**
144
164
* Like {@link #client(MySQLConnectOptions, PoolOptions)} with a specific {@link Vertx} instance.
145
165
*/
146
166
static SqlClient client (Vertx vertx , MySQLConnectOptions connectOptions , PoolOptions poolOptions ) {
147
- return client (vertx , Collections . singletonList ( connectOptions ) , poolOptions );
167
+ return client (vertx , () -> connectOptions , poolOptions );
148
168
}
149
169
150
170
/**
@@ -166,6 +186,26 @@ static SqlClient client(List<MySQLConnectOptions> databases, PoolOptions options
166
186
return client (null , databases , options );
167
187
}
168
188
189
+ /**
190
+ * Like {@link #client(Supplier, PoolOptions)} with a specific {@link Vertx} instance.
191
+ */
192
+ @ GenIgnore
193
+ static SqlClient client (Vertx vertx , Supplier <MySQLConnectOptions > mySQLConnectOptions , PoolOptions options ) {
194
+ return MySQLDriver .INSTANCE .createPool (vertx , mySQLConnectOptions , new MySQLPoolOptions (options ).setPipelined (true ));
195
+ }
196
+
197
+ /**
198
+ * Create a client backed by a connection pool to the MySQL {@code databases}. The supplier is called
199
+ * to provide the options when a new connection is created by the pool.
200
+ *
201
+ * @param databases the databases supplier
202
+ * @param options the options for creating the pool
203
+ * @return the pooled client
204
+ */
205
+ @ GenIgnore
206
+ static SqlClient client (Supplier <MySQLConnectOptions > databases , PoolOptions options ) {
207
+ return client (null , databases , options );
208
+ }
169
209
170
210
@ Override
171
211
MySQLPool connectHandler (Handler <SqlConnection > handler );
0 commit comments