Class Pool

All Implemented Interfaces:
MutinyDelegate

public class Pool extends SqlClient implements MutinyDelegate
A connection pool which reuses a number of SQL connections.

NOTE: This class has been automatically generated from the original non Mutiny-ified interface.

Author:
Julien Viet
See Also:
  • Pool
  • Field Details

    • __TYPE_ARG

      public static final TypeArg<Pool> __TYPE_ARG
  • Constructor Details

    • Pool

      public Pool(io.vertx.sqlclient.Pool delegate)
      Create a new instance of Pool delegating to the given (non-null) instance of Pool.
    • Pool

      public Pool(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.sqlclient.Pool getDelegate()
      Get the delegate instance.

      This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.

      Specified by:
      getDelegate in interface MutinyDelegate
      Overrides:
      getDelegate in class SqlClient
      Returns:
      the delegate instance
    • 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • Pool.getConnection()
    • getConnectionAndAwait

      public SqlConnection getConnectionAndAwait()
      Get a connection from the pool.

      Unlike the bare Vert.x variant, this method returns a SqlConnection. This method awaits indefinitely 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 operation result
      See Also:
      • Pool.getConnection()
    • getConnectionAndForget

      public Pool getConnectionAndForget()
      Get a connection from the pool.

      Unlike the bare Vert.x variant, this method ignores the SqlConnection result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • Pool.getConnection()
    • withTransaction

      @CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> withTransaction(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Execute the given function within a transaction.

      The function is passed a client executing all operations within a transaction. When the uni 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      function - the code to execute
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • Pool.withTransaction(Function)
    • withTransactionAndAwait

      public <T> T withTransactionAndAwait(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Execute the given function within a transaction.

      The function is passed a client executing all operations within a transaction. When the underlying uni 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 Pool. This method awaits indefinitely 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 operation result
      See Also:
      • Pool.withTransaction(Function)
    • withTransactionAndForget

      public <T> Pool withTransactionAndForget(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Execute the given function within a transaction.

      The function is passed a client executing all operations within a transaction. When the underlying uni 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 ignores the Pool result or any failure.

      Parameters:
      function - the code to execute
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • Pool.withTransaction(Function)
    • withTransaction

      @CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> withTransaction(io.vertx.sqlclient.TransactionPropagation txPropagation, Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Like withTransaction(Function) 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • Pool.withTransaction(TransactionPropagation, Function)
    • withTransactionAndAwait

      public <T> T withTransactionAndAwait(io.vertx.sqlclient.TransactionPropagation txPropagation, Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Like withTransaction(Function) 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 Pool. This method awaits indefinitely 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 operation result
      See Also:
      • Pool.withTransaction(TransactionPropagation, Function)
    • withTransactionAndForget

      public <T> Pool withTransactionAndForget(io.vertx.sqlclient.TransactionPropagation txPropagation, Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Like withTransaction(Function) 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 ignores the Pool result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • Pool.withTransaction(TransactionPropagation, 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 given function.

      When the uni 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      function - the code to execute
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • Pool.withConnection(Function)
    • withConnectionAndAwait

      public <T> T withConnectionAndAwait(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Get a connection from the pool and execute the given function.

      When the underlying uni 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 Pool. This method awaits indefinitely 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 operation result
      See Also:
      • Pool.withConnection(Function)
    • withConnectionAndForget

      public <T> Pool withConnectionAndForget(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Get a connection from the pool and execute the given function.

      When the underlying uni 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 ignores the Pool result or any failure.

      Parameters:
      function - the code to execute
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • Pool.withConnection(Function)
    • close

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> close()
      Close the client and release the associated resources.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Overrides:
      close in class SqlClient
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • SqlClient.close()
    • closeAndAwait

      public void closeAndAwait()
      Close the client and release the associated resources.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely 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 class SqlClient
      See Also:
      • SqlClient.close()
    • closeAndForget

      public Pool closeAndForget()
      Close the client and release the associated resources.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Overrides:
      closeAndForget in class SqlClient
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • SqlClient.close()
    • pool

      public static Pool pool(io.vertx.sqlclient.SqlConnectOptions connectOptions)
      Like pool(SqlConnectOptions, PoolOptions) with default options.
    • pool

      public static Pool pool(io.vertx.sqlclient.SqlConnectOptions database, io.vertx.sqlclient.PoolOptions options)
      Like pool(Vertx, SqlConnectOptions, PoolOptions) with a Vert.x instance created automatically.
    • pool

      public static Pool pool(Vertx vertx, io.vertx.sqlclient.SqlConnectOptions database, io.vertx.sqlclient.PoolOptions options)
      Create a connection pool to the database with the given options.

      A Driver will be selected among the drivers found on the classpath returning true when Driver#acceptsOptions(SqlConnectOptions) applied to the first options of the list.

      Parameters:
      vertx - the Vertx instance to be used with the connection pool
      database - the options used to create the connection pool, such as database hostname
      options - the options for creating the pool
      Returns:
      the connection pool
    • query

      public Query<RowSet<Row>> query(String sql)
      Create a query, the Query.execute() method must be called to execute the query. A connection is borrowed from the connection pool when the query is executed and then immediately returned to the pool after it completes.
      Overrides:
      query in class SqlClient
      Returns:
      the query
    • preparedQuery

      public PreparedQuery<RowSet<Row>> preparedQuery(String sql)
      Create a prepared query, one of the PreparedQuery.execute(io.vertx.mutiny.sqlclient.Tuple) or PreparedQuery.executeBatch(java.util.List<io.vertx.mutiny.sqlclient.Tuple>) methods must be called to execute the query. A connection is borrowed from the connection pool when the query is executed and then immediately returned to the pool after it completes.
      Overrides:
      preparedQuery in class SqlClient
      Returns:
      the prepared query
    • size

      public int size()
      Returns:
      the current pool size approximation
    • newInstance

      public static Pool newInstance(io.vertx.sqlclient.Pool delegate)
      Creates a new instance of the Pool.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class SqlClient
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class SqlClient
    • toString

      public String toString()
      Overrides:
      toString in class SqlClient