Class Pool

    • Field Detail

      • __TYPE_ARG

        public static final TypeArg<Pool> __TYPE_ARG
    • Constructor Detail

      • Pool

        public Pool​(Pool delegate)
      • Pool

        public Pool​(Object delegate)
    • Method Detail

      • pool

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

        A will be selected among the drivers found on the classpath returning true when 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
      • getConnection

        public io.reactivex.rxjava3.core.Single<SqlConnection> getConnection()
        Get a connection from the pool.
        Returns:
      • rxGetConnection

        public io.reactivex.rxjava3.core.Single<SqlConnection> rxGetConnection()
        Get a connection from the pool.
        Returns:
      • query

        public Query<RowSet<Row>> query​(String sql)
        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
        Parameters:
        sql -
        Returns:
      • preparedQuery

        public PreparedQuery<RowSet<Row>> preparedQuery​(String sql)
        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
        Parameters:
        sql -
        Returns:
      • withTransaction

        public <T> io.reactivex.rxjava3.core.Maybe<T> withTransaction​(Function<SqlConnection,​io.reactivex.rxjava3.core.Maybe<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.

        Parameters:
        function - the code to execute
        Returns:
      • rxWithTransaction

        public <T> io.reactivex.rxjava3.core.Maybe<T> rxWithTransaction​(Function<SqlConnection,​io.reactivex.rxjava3.core.Maybe<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.

        Parameters:
        function - the code to execute
        Returns:
      • withConnection

        public <T> io.reactivex.rxjava3.core.Maybe<T> withConnection​(Function<SqlConnection,​io.reactivex.rxjava3.core.Maybe<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.

        Parameters:
        function - the code to execute
        Returns:
      • rxWithConnection

        public <T> io.reactivex.rxjava3.core.Maybe<T> rxWithConnection​(Function<SqlConnection,​io.reactivex.rxjava3.core.Maybe<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.

        Parameters:
        function - the code to execute
        Returns:
      • close

        public io.reactivex.rxjava3.core.Completable close()
        Close the pool and release the associated resources.
        Overrides:
        close in class SqlClient
        Returns:
      • rxClose

        public io.reactivex.rxjava3.core.Completable rxClose()
        Close the pool and release the associated resources.
        Overrides:
        rxClose in class SqlClient
        Returns:
      • connectHandler

        @Deprecated
        public Pool connectHandler​(Handler<SqlConnection> handler)
        Deprecated.
        Set an handler called when the pool has established a connection to the database.

        This handler allows interactions with the database before the connection is added to the pool.

        When the handler has finished, it must call SqlClient.close() to release the connection to the pool.

        Parameters:
        handler - the handler
        Returns:
        a reference to this, so the API can be used fluently
      • connectionProvider

        @Deprecated
        public Pool connectionProvider​(Function<Context,​io.reactivex.rxjava3.core.Single<SqlConnection>> provider)
        Deprecated.
        Replace the default pool connection provider, the new provider returns a future connection for a given .

        A ConnectionFactory can be used as connection 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​(Pool arg)