Class Pool
- java.lang.Object
-
- io.vertx.mutiny.sqlclient.SqlClient
-
- io.vertx.mutiny.sqlclient.Pool
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<Pool>
__TYPE_ARG
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description io.smallrye.mutiny.Uni<Void>
close()
Close the pool and release the associated resources.Void
closeAndAwait()
Blocking variant ofSqlClient.close()
.void
closeAndForget()
Variant ofSqlClient.close()
that ignores the result of the operation.Pool
connectHandler(Consumer<SqlConnection> handler)
Pool
connectionProvider(Function<Context,io.smallrye.mutiny.Uni<SqlConnection>> provider)
boolean
equals(Object o)
io.smallrye.mutiny.Uni<SqlConnection>
getConnection()
Get a connection from the pool.SqlConnection
getConnectionAndAwait()
Blocking variant ofgetConnection()
.void
getConnectionAndForget()
Variant ofgetConnection()
that ignores the result of the operation.io.vertx.sqlclient.Pool
getDelegate()
int
hashCode()
static Pool
newInstance(io.vertx.sqlclient.Pool arg)
static Pool
pool(Vertx vertx, io.vertx.sqlclient.SqlConnectOptions database, io.vertx.sqlclient.PoolOptions options)
static Pool
pool(io.vertx.sqlclient.SqlConnectOptions connectOptions)
static Pool
pool(io.vertx.sqlclient.SqlConnectOptions database, io.vertx.sqlclient.PoolOptions options)
PreparedQuery<RowSet<Row>>
preparedQuery(String sql)
Query<RowSet<Row>>
query(String sql)
int
size()
String
toString()
<T> io.smallrye.mutiny.Uni<T>
withConnection(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Get a connection from the pool and execute the givenfunction
.<T> T
withConnectionAndAwait(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Blocking variant ofio.vertx.mutiny.sqlclient.Pool#withConnection(Function
.>) <T> void
withConnectionAndForget(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Variant ofio.vertx.mutiny.sqlclient.Pool#withConnection(Function
that ignores the result of the operation.>) <T> io.smallrye.mutiny.Uni<T>
withTransaction(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Execute the givenfunction
within a transaction.<T> T
withTransactionAndAwait(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Blocking variant ofio.vertx.mutiny.sqlclient.Pool#withTransaction(Function
.>) <T> void
withTransactionAndForget(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Variant ofio.vertx.mutiny.sqlclient.Pool#withTransaction(Function
that ignores the result of the operation.>) -
Methods inherited from class io.vertx.mutiny.sqlclient.SqlClient
newInstance
-
-
-
-
Constructor Detail
-
Pool
public Pool(io.vertx.sqlclient.Pool delegate)
-
Pool
public Pool(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.sqlclient.Pool getDelegate()
- Overrides:
getDelegate
in classSqlClient
-
pool
public static Pool pool(io.vertx.sqlclient.SqlConnectOptions connectOptions)
- Parameters:
connectOptions
-- Returns:
-
pool
public static Pool pool(io.vertx.sqlclient.SqlConnectOptions database, io.vertx.sqlclient.PoolOptions options)
- Parameters:
database
-options
-- Returns:
-
pool
public static Pool pool(Vertx vertx, io.vertx.sqlclient.SqlConnectOptions database, io.vertx.sqlclient.PoolOptions options)
- Parameters:
vertx
- the Vertx instance to be used with the connection pooldatabase
- the options used to create the connection pool, such as database hostnameoptions
- the options for creating the pool- Returns:
- the connection pool
-
getConnection
public io.smallrye.mutiny.Uni<SqlConnection> getConnection()
Get a connection from the pool.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
getConnectionAndAwait
public SqlConnection getConnectionAndAwait()
Blocking variant ofgetConnection()
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the SqlConnection instance produced by the operation.
-
getConnectionAndForget
public void getConnectionAndForget()
Variant ofgetConnection()
that ignores the result of the operation.This method subscribes on the result of
getConnection()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromgetConnection()
but you don't need to compose it with other operations.
-
preparedQuery
public PreparedQuery<RowSet<Row>> preparedQuery(String sql)
- Overrides:
preparedQuery
in classSqlClient
- Parameters:
sql
-- Returns:
-
withTransaction
public <T> io.smallrye.mutiny.Uni<T> withTransaction(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Execute the givenfunction
within a transaction.The
function
is passed a client executing all operations within a transaction. When the future returned by the function- succeeds the transaction commits
- fails the transaction rollbacks
The
handler
is given a success result when the function returns a succeeded futures and the transaction commits. Otherwise it is given a failure result.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
function
- the code to execute- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
withTransactionAndAwait
public <T> T withTransactionAndAwait(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Blocking variant ofio.vertx.mutiny.sqlclient.Pool#withTransaction(Function
.>) This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
function
- the code to execute- Returns:
- the T instance produced by the operation.
-
withTransactionAndForget
public <T> void withTransactionAndForget(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Variant ofio.vertx.mutiny.sqlclient.Pool#withTransaction(Function
that ignores the result of the operation.>) This method subscribes on the result of
io.vertx.mutiny.sqlclient.Pool#withTransaction(Function
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from>) io.vertx.mutiny.sqlclient.Pool#withTransaction(Function
but you don't need to compose it with other operations.>) - Parameters:
function
- the code to execute
-
withConnection
public <T> io.smallrye.mutiny.Uni<T> withConnection(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Get a connection from the pool and execute the givenfunction
.When the future returned by the
function
completes, the connection is returned to the pool.The
handler
is given a success result when the function returns a succeeded futures. Otherwise it is given a failure result.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
function
- the code to execute- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
withConnectionAndAwait
public <T> T withConnectionAndAwait(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Blocking variant ofio.vertx.mutiny.sqlclient.Pool#withConnection(Function
.>) This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
function
- the code to execute- Returns:
- the T instance produced by the operation.
-
withConnectionAndForget
public <T> void withConnectionAndForget(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Variant ofio.vertx.mutiny.sqlclient.Pool#withConnection(Function
that ignores the result of the operation.>) This method subscribes on the result of
io.vertx.mutiny.sqlclient.Pool#withConnection(Function
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from>) io.vertx.mutiny.sqlclient.Pool#withConnection(Function
but you don't need to compose it with other operations.>) - Parameters:
function
- the code to execute
-
close
public io.smallrye.mutiny.Uni<Void> close()
Close the pool and release the associated resources.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.
-
closeAndAwait
public Void closeAndAwait()
Blocking variant ofSqlClient.close()
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Overrides:
closeAndAwait
in classSqlClient
- Returns:
- the Void instance produced by the operation.
-
closeAndForget
public void closeAndForget()
Variant ofSqlClient.close()
that ignores the result of the operation.This method subscribes on the result of
SqlClient.close()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromSqlClient.close()
but you don't need to compose it with other operations.- Overrides:
closeAndForget
in classSqlClient
-
connectHandler
public Pool connectHandler(Consumer<SqlConnection> handler)
- Parameters:
handler
- the handler- Returns:
-
connectionProvider
public Pool connectionProvider(Function<Context,io.smallrye.mutiny.Uni<SqlConnection>> provider)
- Parameters:
provider
- the new connection provider- Returns:
- a reference to this, so the API can be used fluently
-
size
public int size()
- Returns:
- the current pool size approximation
-
newInstance
public static Pool newInstance(io.vertx.sqlclient.Pool arg)
-
-