Class Pool
- All Implemented Interfaces:
MutinyDelegate
original non Mutiny-ified interface using Vert.x codegen.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.smallrye.mutiny.Uni<Void>close()Close the pool and release the associated resources.Blocking variant ofSqlClient.close().voidVariant ofSqlClient.close()that ignores the result of the operation.connectHandler(Consumer<SqlConnection> handler) Deprecated.connectionProvider(Function<Context, io.smallrye.mutiny.Uni<SqlConnection>> provider) Deprecated.instead useClientBuilder.connectingTo(Supplier)booleanio.smallrye.mutiny.Uni<SqlConnection>Get a connection from the pool.Blocking variant ofgetConnection().voidVariant ofgetConnection()that ignores the result of the operation.io.vertx.sqlclient.PoolinthashCode()static PoolnewInstance(io.vertx.sqlclient.Pool arg) static Poolpool(Vertx vertx, io.vertx.sqlclient.SqlConnectOptions database, io.vertx.sqlclient.PoolOptions options) static Poolpool(io.vertx.sqlclient.SqlConnectOptions connectOptions) static Poolpool(io.vertx.sqlclient.SqlConnectOptions database, io.vertx.sqlclient.PoolOptions options) preparedQuery(String sql) intsize()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> TwithConnectionAndAwait(Function<SqlConnection, io.smallrye.mutiny.Uni<T>> function) Blocking variant ofwithConnection(Function).<T> voidwithConnectionAndForget(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 givenfunctionwithin a transaction.<T> TwithTransactionAndAwait(io.vertx.sqlclient.TransactionPropagation txPropagation, Function<SqlConnection, io.smallrye.mutiny.Uni<T>> function) Blocking variant ofwithTransaction(TransactionPropagation,Function).<T> TwithTransactionAndAwait(Function<SqlConnection, io.smallrye.mutiny.Uni<T>> function) Blocking variant ofwithTransaction(Function).<T> voidwithTransactionAndForget(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> voidwithTransactionAndForget(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
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
Pool
public Pool(io.vertx.sqlclient.Pool delegate) -
Pool
-
-
Method Details
-
getDelegate
public io.vertx.sqlclient.Pool getDelegate()- Specified by:
getDelegatein interfaceMutinyDelegate- Overrides:
getDelegatein classSqlClient- Returns:
- the delegate used by this Mutiny object of generated type
-
toString
-
equals
-
hashCode
public int hashCode() -
pool
- 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
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
unifiring the result of the operation when completed, or a failure if the operation failed.
-
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. -
query
-
preparedQuery
- Overrides:
preparedQueryin classSqlClient- Parameters:
sql-- Returns:
-
withTransaction
@CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> withTransaction(Function<SqlConnection, io.smallrye.mutiny.Uni<T>> function) Execute the givenfunctionwithin a transaction.The
functionis 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
handleris 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
unifiring the result of the operation when completed, or a failure if the operation failed.
-
withTransactionAndAwait
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
unifiring 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
functioncompletes, the connection is returned to the pool.The
handleris 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
unifiring the result of the operation when completed, or a failure if the operation failed.
-
withConnectionAndAwait
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
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
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
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:
closeAndAwaitin 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:
closeAndForgetin classSqlClient
-
connectHandler
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
-
ClientBuilder#withConnectHandler(Handler)