Class Pool

  • Direct Known Subclasses:
    DB2Pool, JDBCPool, MSSQLPool, MySQLPool, OraclePool, PgPool

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

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

    • Field Detail

      • __TYPE_ARG

        public static final TypeArg<Pool> __TYPE_ARG
    • 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 class SqlClient
      • 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 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
      • 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 of getConnection().

        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 of getConnection() 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 from getConnection() but you don't need to compose it with other operations.

      • 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 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 of 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 of withTransaction(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 from withTransaction(Function) but you don't need to compose it with other operations.

        Parameters:
        function - the code to execute
      • 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 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 of 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 of withConnection(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 from withConnection(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.

        Overrides:
        close in class SqlClient
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • closeAndAwait

        public Void closeAndAwait()
        Blocking variant of SqlClient.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 class SqlClient
        Returns:
        the Void instance produced by the operation.
      • closeAndForget

        public void closeAndForget()
        Variant of SqlClient.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 from SqlClient.close() but you don't need to compose it with other operations.

        Overrides:
        closeAndForget in class SqlClient
      • 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)