/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.reactiverse.reactivex.pgclient;

import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.Maybe;
import io.reactiverse.pgclient.PgConnectOptions;
import java.util.List;
import io.reactiverse.pgclient.PgPoolOptions;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;

Defines the client operations with a Postgres Database.

NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.
/** * Defines the client operations with a Postgres Database. * * <p/> * NOTE: This class has been automatically generated from the {@link io.reactiverse.pgclient.PgClient original} non RX-ified interface using Vert.x codegen. */
@io.vertx.lang.rx.RxGen(io.reactiverse.pgclient.PgClient.class) public class PgClient { @Override public String toString() { return delegate.toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PgClient that = (PgClient) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final io.vertx.lang.rx.TypeArg<PgClient> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new PgClient((io.reactiverse.pgclient.PgClient) obj), PgClient::getDelegate ); private final io.reactiverse.pgclient.PgClient delegate; public PgClient(io.reactiverse.pgclient.PgClient delegate) { this.delegate = delegate; } public io.reactiverse.pgclient.PgClient getDelegate() { return delegate; }
Like pool with options build from the environment variables.
Returns:
/** * Like {@link io.reactiverse.reactivex.pgclient.PgClient#pool} with options build from the environment variables. * @return */
public static io.reactiverse.reactivex.pgclient.PgPool pool() { io.reactiverse.reactivex.pgclient.PgPool ret = io.reactiverse.reactivex.pgclient.PgPool.newInstance(io.reactiverse.pgclient.PgClient.pool()); return ret; }
Like pool with options build from connectionUri.
Params:
  • connectionUri –
Returns:
/** * Like {@link io.reactiverse.reactivex.pgclient.PgClient#pool} with options build from <code>connectionUri</code>. * @param connectionUri * @return */
public static io.reactiverse.reactivex.pgclient.PgPool pool(String connectionUri) { io.reactiverse.reactivex.pgclient.PgPool ret = io.reactiverse.reactivex.pgclient.PgPool.newInstance(io.reactiverse.pgclient.PgClient.pool(connectionUri)); return ret; }
Like pool with options build from the environment variables.
Params:
  • vertx –
Returns:
/** * Like {@link io.reactiverse.reactivex.pgclient.PgClient#pool} with options build from the environment variables. * @param vertx * @return */
public static io.reactiverse.reactivex.pgclient.PgPool pool(io.vertx.reactivex.core.Vertx vertx) { io.reactiverse.reactivex.pgclient.PgPool ret = io.reactiverse.reactivex.pgclient.PgPool.newInstance(io.reactiverse.pgclient.PgClient.pool(vertx.getDelegate())); return ret; }
Like pool with options build from connectionUri.
Params:
  • vertx –
  • connectionUri –
Returns:
/** * Like {@link io.reactiverse.reactivex.pgclient.PgClient#pool} with options build from <code>connectionUri</code>. * @param vertx * @param connectionUri * @return */
public static io.reactiverse.reactivex.pgclient.PgPool pool(io.vertx.reactivex.core.Vertx vertx, String connectionUri) { io.reactiverse.reactivex.pgclient.PgPool ret = io.reactiverse.reactivex.pgclient.PgPool.newInstance(io.reactiverse.pgclient.PgClient.pool(vertx.getDelegate(), connectionUri)); return ret; }
Create a connection pool to the database configured with the given options.
Params:
  • options – the options for creating the pool
Returns:the connection pool
/** * Create a connection pool to the database configured with the given <code>options</code>. * @param options the options for creating the pool * @return the connection pool */
public static io.reactiverse.reactivex.pgclient.PgPool pool(PgPoolOptions options) { io.reactiverse.reactivex.pgclient.PgPool ret = io.reactiverse.reactivex.pgclient.PgPool.newInstance(io.reactiverse.pgclient.PgClient.pool(options)); return ret; }
Like pool with a specific instance.
Params:
  • vertx –
  • options –
Returns:
/** * Like {@link io.reactiverse.reactivex.pgclient.PgClient#pool} with a specific instance. * @param vertx * @param options * @return */
public static io.reactiverse.reactivex.pgclient.PgPool pool(io.vertx.reactivex.core.Vertx vertx, PgPoolOptions options) { io.reactiverse.reactivex.pgclient.PgPool ret = io.reactiverse.reactivex.pgclient.PgPool.newInstance(io.reactiverse.pgclient.PgClient.pool(vertx.getDelegate(), options)); return ret; }
Connects to the database and returns the connection if that succeeds.

The connection interracts directly with the database is not a proxy, so closing the connection will close the underlying connection to the database.
Params:
  • vertx – the vertx instance
  • options – the connect options
  • handler – the handler called with the connection or the failure
/** * Connects to the database and returns the connection if that succeeds. * <p/> * The connection interracts directly with the database is not a proxy, so closing the * connection will close the underlying connection to the database. * @param vertx the vertx instance * @param options the connect options * @param handler the handler called with the connection or the failure */
public static void connect(io.vertx.reactivex.core.Vertx vertx, PgConnectOptions options, Handler<AsyncResult<io.reactiverse.reactivex.pgclient.PgConnection>> handler) { io.reactiverse.pgclient.PgClient.connect(vertx.getDelegate(), options, new Handler<AsyncResult<io.reactiverse.pgclient.PgConnection>>() { public void handle(AsyncResult<io.reactiverse.pgclient.PgConnection> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.reactivex.pgclient.PgConnection.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
Connects to the database and returns the connection if that succeeds.

The connection interracts directly with the database is not a proxy, so closing the connection will close the underlying connection to the database.
Params:
  • vertx – the vertx instance
  • options – the connect options
Returns:
/** * Connects to the database and returns the connection if that succeeds. * <p/> * The connection interracts directly with the database is not a proxy, so closing the * connection will close the underlying connection to the database. * @param vertx the vertx instance * @param options the connect options * @return */
public static Single<io.reactiverse.reactivex.pgclient.PgConnection> rxConnect(io.vertx.reactivex.core.Vertx vertx, PgConnectOptions options) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { connect(vertx, options, handler); }); }
Like connect with options build from the environment variables.
Params:
  • vertx –
  • handler –
/** * Like {@link io.reactiverse.reactivex.pgclient.PgClient#connect} with options build from the environment variables. * @param vertx * @param handler */
public static void connect(io.vertx.reactivex.core.Vertx vertx, Handler<AsyncResult<io.reactiverse.reactivex.pgclient.PgConnection>> handler) { io.reactiverse.pgclient.PgClient.connect(vertx.getDelegate(), new Handler<AsyncResult<io.reactiverse.pgclient.PgConnection>>() { public void handle(AsyncResult<io.reactiverse.pgclient.PgConnection> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.reactivex.pgclient.PgConnection.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
Like connect with options build from the environment variables.
Params:
  • vertx –
Returns:
/** * Like {@link io.reactiverse.reactivex.pgclient.PgClient#connect} with options build from the environment variables. * @param vertx * @return */
public static Single<io.reactiverse.reactivex.pgclient.PgConnection> rxConnect(io.vertx.reactivex.core.Vertx vertx) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { connect(vertx, handler); }); }
Like connect with options build from connectionUri.
Params:
  • vertx –
  • connectionUri –
  • handler –
/** * Like {@link io.reactiverse.reactivex.pgclient.PgClient#connect} with options build from <code>connectionUri</code>. * @param vertx * @param connectionUri * @param handler */
public static void connect(io.vertx.reactivex.core.Vertx vertx, String connectionUri, Handler<AsyncResult<io.reactiverse.reactivex.pgclient.PgConnection>> handler) { io.reactiverse.pgclient.PgClient.connect(vertx.getDelegate(), connectionUri, new Handler<AsyncResult<io.reactiverse.pgclient.PgConnection>>() { public void handle(AsyncResult<io.reactiverse.pgclient.PgConnection> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.reactivex.pgclient.PgConnection.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
Like connect with options build from connectionUri.
Params:
  • vertx –
  • connectionUri –
Returns:
/** * Like {@link io.reactiverse.reactivex.pgclient.PgClient#connect} with options build from <code>connectionUri</code>. * @param vertx * @param connectionUri * @return */
public static Single<io.reactiverse.reactivex.pgclient.PgConnection> rxConnect(io.vertx.reactivex.core.Vertx vertx, String connectionUri) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { connect(vertx, connectionUri, handler); }); }
Execute a simple query.
Params:
  • sql – the query SQL
  • handler – the handler notified with the execution result
Returns:a reference to this, so the API can be used fluently
/** * Execute a simple query. * @param sql the query SQL * @param handler the handler notified with the execution result * @return a reference to this, so the API can be used fluently */
public io.reactiverse.reactivex.pgclient.PgClient query(String sql, Handler<AsyncResult<io.reactiverse.reactivex.pgclient.PgRowSet>> handler) { delegate.query(sql, new Handler<AsyncResult<io.reactiverse.pgclient.PgRowSet>>() { public void handle(AsyncResult<io.reactiverse.pgclient.PgRowSet> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.reactivex.pgclient.PgRowSet.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
Execute a simple query.
Params:
  • sql – the query SQL
Returns:a reference to this, so the API can be used fluently
/** * Execute a simple query. * @param sql the query SQL * @return a reference to this, so the API can be used fluently */
public Single<io.reactiverse.reactivex.pgclient.PgRowSet> rxQuery(String sql) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { query(sql, handler); }); }
Prepare and execute a query.
Params:
  • sql – the prepared query SQL
  • handler – the handler notified with the execution result
Returns:a reference to this, so the API can be used fluently
/** * Prepare and execute a query. * @param sql the prepared query SQL * @param handler the handler notified with the execution result * @return a reference to this, so the API can be used fluently */
public io.reactiverse.reactivex.pgclient.PgClient preparedQuery(String sql, Handler<AsyncResult<io.reactiverse.reactivex.pgclient.PgRowSet>> handler) { delegate.preparedQuery(sql, new Handler<AsyncResult<io.reactiverse.pgclient.PgRowSet>>() { public void handle(AsyncResult<io.reactiverse.pgclient.PgRowSet> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.reactivex.pgclient.PgRowSet.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
Prepare and execute a query.
Params:
  • sql – the prepared query SQL
Returns:a reference to this, so the API can be used fluently
/** * Prepare and execute a query. * @param sql the prepared query SQL * @return a reference to this, so the API can be used fluently */
public Single<io.reactiverse.reactivex.pgclient.PgRowSet> rxPreparedQuery(String sql) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { preparedQuery(sql, handler); }); }
Prepare and execute a query.
Params:
  • sql – the prepared query SQL
  • arguments – the list of arguments
  • handler – the handler notified with the execution result
Returns:a reference to this, so the API can be used fluently
/** * Prepare and execute a query. * @param sql the prepared query SQL * @param arguments the list of arguments * @param handler the handler notified with the execution result * @return a reference to this, so the API can be used fluently */
public io.reactiverse.reactivex.pgclient.PgClient preparedQuery(String sql, io.reactiverse.reactivex.pgclient.Tuple arguments, Handler<AsyncResult<io.reactiverse.reactivex.pgclient.PgRowSet>> handler) { delegate.preparedQuery(sql, arguments.getDelegate(), new Handler<AsyncResult<io.reactiverse.pgclient.PgRowSet>>() { public void handle(AsyncResult<io.reactiverse.pgclient.PgRowSet> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.reactivex.pgclient.PgRowSet.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
Prepare and execute a query.
Params:
  • sql – the prepared query SQL
  • arguments – the list of arguments
Returns:a reference to this, so the API can be used fluently
/** * Prepare and execute a query. * @param sql the prepared query SQL * @param arguments the list of arguments * @return a reference to this, so the API can be used fluently */
public Single<io.reactiverse.reactivex.pgclient.PgRowSet> rxPreparedQuery(String sql, io.reactiverse.reactivex.pgclient.Tuple arguments) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { preparedQuery(sql, arguments, handler); }); }
Prepare and execute a createBatch.
Params:
  • sql – the prepared query SQL
  • batch – the batch of tuples
  • handler – the handler notified with the execution result
Returns:a reference to this, so the API can be used fluently
/** * Prepare and execute a createBatch. * @param sql the prepared query SQL * @param batch the batch of tuples * @param handler the handler notified with the execution result * @return a reference to this, so the API can be used fluently */
public io.reactiverse.reactivex.pgclient.PgClient preparedBatch(String sql, List<io.reactiverse.reactivex.pgclient.Tuple> batch, Handler<AsyncResult<io.reactiverse.reactivex.pgclient.PgRowSet>> handler) { delegate.preparedBatch(sql, batch.stream().map(elt -> elt.getDelegate()).collect(java.util.stream.Collectors.toList()), new Handler<AsyncResult<io.reactiverse.pgclient.PgRowSet>>() { public void handle(AsyncResult<io.reactiverse.pgclient.PgRowSet> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.reactivex.pgclient.PgRowSet.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
Prepare and execute a createBatch.
Params:
  • sql – the prepared query SQL
  • batch – the batch of tuples
Returns:a reference to this, so the API can be used fluently
/** * Prepare and execute a createBatch. * @param sql the prepared query SQL * @param batch the batch of tuples * @return a reference to this, so the API can be used fluently */
public Single<io.reactiverse.reactivex.pgclient.PgRowSet> rxPreparedBatch(String sql, List<io.reactiverse.reactivex.pgclient.Tuple> batch) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { preparedBatch(sql, batch, handler); }); }
Close the client and release the associated resources.
/** * Close the client and release the associated resources. */
public void close() { delegate.close(); } public static PgClient newInstance(io.reactiverse.pgclient.PgClient arg) { return arg != null ? new PgClient(arg) : null; } }