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 Deprecated 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)
Deprecated.instead useClientBuilder#withConnectHandler(Handler)
Pool
connectionProvider(Function<Context,io.smallrye.mutiny.Uni<SqlConnection>> provider)
Deprecated.instead useClientBuilder.connectingTo(Supplier)
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 ofwithConnection(Function)
.<T> void
withConnectionAndForget(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Variant ofwithConnection(Function)
that ignores the result of the operation.<T> io.smallrye.mutiny.Uni<T>
withTransaction(io.vertx.sqlclient.TransactionPropagation txPropagation, Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
LikewithTransaction(java.util.function.Function<io.vertx.mutiny.sqlclient.SqlConnection, io.smallrye.mutiny.Uni<T>>)
but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.<T> io.smallrye.mutiny.Uni<T>
withTransaction(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Execute the givenfunction
within a transaction.<T> T
withTransactionAndAwait(io.vertx.sqlclient.TransactionPropagation txPropagation, Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Blocking variant ofwithTransaction(TransactionPropagation,Function)
.<T> T
withTransactionAndAwait(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Blocking variant ofwithTransaction(Function)
.<T> void
withTransactionAndForget(io.vertx.sqlclient.TransactionPropagation txPropagation, Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Variant ofwithTransaction(TransactionPropagation,Function)
that ignores the result of the operation.<T> void
withTransactionAndForget(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Variant ofwithTransaction(Function)
that ignores the result of the operation.-
Methods inherited from class io.vertx.mutiny.sqlclient.SqlClient
newInstance, preparedQuery
-
-
-
-
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
@CheckReturnValue 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
@CheckReturnValue 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 ofwithTransaction(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 ofwithTransaction(Function)
that ignores the result of the operation.This method subscribes on the result of
withTransaction(Function)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromwithTransaction(Function)
but you don't need to compose it with other operations.- Parameters:
function
- the code to execute
-
withTransaction
@CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> withTransaction(io.vertx.sqlclient.TransactionPropagation txPropagation, Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
LikewithTransaction(java.util.function.Function<io.vertx.mutiny.sqlclient.SqlConnection, io.smallrye.mutiny.Uni<T>>)
but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
txPropagation
-function
-- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
withTransactionAndAwait
public <T> T withTransactionAndAwait(io.vertx.sqlclient.TransactionPropagation txPropagation, Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Blocking variant ofwithTransaction(TransactionPropagation,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:
txPropagation
-function
-- Returns:
- the T instance produced by the operation.
-
withTransactionAndForget
public <T> void withTransactionAndForget(io.vertx.sqlclient.TransactionPropagation txPropagation, Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
Variant ofwithTransaction(TransactionPropagation,Function)
that ignores the result of the operation.This method subscribes on the result of
withTransaction(TransactionPropagation,Function)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromwithTransaction(TransactionPropagation,Function)
but you don't need to compose it with other operations.- Parameters:
txPropagation
-function
-
-
withConnection
@CheckReturnValue 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 ofwithConnection(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 ofwithConnection(Function)
that ignores the result of the operation.This method subscribes on the result of
withConnection(Function)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromwithConnection(Function)
but you don't need to compose it with other operations.- Parameters:
function
- the code to execute
-
close
@CheckReturnValue 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
@Deprecated public Pool connectHandler(Consumer<SqlConnection> handler)
Deprecated.instead useClientBuilder#withConnectHandler(Handler)
- Parameters:
handler
- the handler- Returns:
-
connectionProvider
@Deprecated public Pool connectionProvider(Function<Context,io.smallrye.mutiny.Uni<SqlConnection>> provider)
Deprecated.instead useClientBuilder.connectingTo(Supplier)
- 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)
-
-