1212package io .vertx .mysqlclient ;
1313
1414import io .vertx .codegen .annotations .Fluent ;
15+ import io .vertx .codegen .annotations .GenIgnore ;
1516import io .vertx .codegen .annotations .VertxGen ;
1617import io .vertx .core .Context ;
1718import io .vertx .core .Future ;
2425import io .vertx .sqlclient .SqlClient ;
2526import io .vertx .sqlclient .SqlConnection ;
2627
27- import java .util .Collections ;
2828import java .util .List ;
2929import java .util .function .Function ;
30+ import java .util .function .Supplier ;
3031
3132import static io .vertx .mysqlclient .MySQLConnectOptions .fromUri ;
3233
@@ -79,7 +80,7 @@ static MySQLPool pool(MySQLConnectOptions database, PoolOptions options) {
7980 * Like {@link #pool(MySQLConnectOptions, PoolOptions)} with a specific {@link Vertx} instance.
8081 */
8182 static MySQLPool pool (Vertx vertx , MySQLConnectOptions database , PoolOptions options ) {
82- return pool (vertx , Collections . singletonList ( database ) , options );
83+ return pool (vertx , () -> database , options );
8384 }
8485
8586 /**
@@ -101,7 +102,26 @@ static MySQLPool pool(Vertx vertx, List<MySQLConnectOptions> databases, PoolOpti
101102 return (MySQLPool ) MySQLDriver .INSTANCE .createPool (vertx , databases , options );
102103 }
103104
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+ }
104117
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+ }
105125 /**
106126 * Like {@link #client(String, PoolOptions)} with a default {@code poolOptions}.
107127 */
@@ -137,14 +157,14 @@ static SqlClient client(Vertx vertx, String connectionUri, PoolOptions poolOptio
137157 * @return the client
138158 */
139159 static SqlClient client (MySQLConnectOptions connectOptions , PoolOptions poolOptions ) {
140- return client (null , Collections . singletonList ( connectOptions ) , poolOptions );
160+ return client (null , () -> connectOptions , poolOptions );
141161 }
142162
143163 /**
144164 * Like {@link #client(MySQLConnectOptions, PoolOptions)} with a specific {@link Vertx} instance.
145165 */
146166 static SqlClient client (Vertx vertx , MySQLConnectOptions connectOptions , PoolOptions poolOptions ) {
147- return client (vertx , Collections . singletonList ( connectOptions ) , poolOptions );
167+ return client (vertx , () -> connectOptions , poolOptions );
148168 }
149169
150170 /**
@@ -166,6 +186,26 @@ static SqlClient client(List<MySQLConnectOptions> databases, PoolOptions options
166186 return client (null , databases , options );
167187 }
168188
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+ }
169209
170210 @ Override
171211 MySQLPool connectHandler (Handler <SqlConnection > handler );
0 commit comments