All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.reactiverse.mutiny.pgclient.PgClient Maven / Gradle / Ivy

There is a newer version: 1.6.0
Show newest version
package io.reactiverse.mutiny.pgclient;

import java.util.Map;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;
import java.util.function.Consumer;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Publisher;
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 {@link io.reactiverse.pgclient.PgClient original} non Mutiny-ified interface using Vert.x codegen. */ @io.smallrye.mutiny.vertx.MutinyGen(io.reactiverse.pgclient.PgClient.class) public class PgClient { public static final io.smallrye.mutiny.vertx.TypeArg __TYPE_ARG = new io.smallrye.mutiny.vertx.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; } /** * Empty constructor used by CDI, do not use this constructor directly. **/ PgClient() { this.delegate = null; } public io.reactiverse.pgclient.PgClient getDelegate() { return delegate; } @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(); } /** * Like {@link io.reactiverse.mutiny.pgclient.PgClient#pool} with options build from the environment variables. * @return */ public static io.reactiverse.mutiny.pgclient.PgPool pool() { io.reactiverse.mutiny.pgclient.PgPool ret = io.reactiverse.mutiny.pgclient.PgPool.newInstance(io.reactiverse.pgclient.PgClient.pool()); return ret; } /** * Like {@link io.reactiverse.mutiny.pgclient.PgClient#pool} with options build from connectionUri. * @param connectionUri * @return */ public static io.reactiverse.mutiny.pgclient.PgPool pool(String connectionUri) { io.reactiverse.mutiny.pgclient.PgPool ret = io.reactiverse.mutiny.pgclient.PgPool.newInstance(io.reactiverse.pgclient.PgClient.pool(connectionUri)); return ret; } /** * Like {@link io.reactiverse.mutiny.pgclient.PgClient#pool} with options build from the environment variables. * @param vertx * @return */ public static io.reactiverse.mutiny.pgclient.PgPool pool(io.vertx.mutiny.core.Vertx vertx) { io.reactiverse.mutiny.pgclient.PgPool ret = io.reactiverse.mutiny.pgclient.PgPool.newInstance(io.reactiverse.pgclient.PgClient.pool(vertx.getDelegate())); return ret; } /** * Like {@link io.reactiverse.mutiny.pgclient.PgClient#pool} with options build from connectionUri. * @param vertx * @param connectionUri * @return */ public static io.reactiverse.mutiny.pgclient.PgPool pool(io.vertx.mutiny.core.Vertx vertx, String connectionUri) { io.reactiverse.mutiny.pgclient.PgPool ret = io.reactiverse.mutiny.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. * @param options the options for creating the pool * @return the connection pool */ public static io.reactiverse.mutiny.pgclient.PgPool pool(PgPoolOptions options) { io.reactiverse.mutiny.pgclient.PgPool ret = io.reactiverse.mutiny.pgclient.PgPool.newInstance(io.reactiverse.pgclient.PgClient.pool(options)); return ret; } /** * Like {@link io.reactiverse.mutiny.pgclient.PgClient#pool} with a specific instance. * @param vertx * @param options * @return */ public static io.reactiverse.mutiny.pgclient.PgPool pool(io.vertx.mutiny.core.Vertx vertx, PgPoolOptions options) { io.reactiverse.mutiny.pgclient.PgPool ret = io.reactiverse.mutiny.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. * @param vertx the vertx instance * @param options the connect options * @param handler the handler called with the connection or the failure */ private static void __connect(io.vertx.mutiny.core.Vertx vertx, PgConnectOptions options, Handler> handler) { io.reactiverse.pgclient.PgClient.connect(vertx.getDelegate(), options, new Handler>() { public void handle(AsyncResult ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.mutiny.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. * @param vertx the vertx instance * @param options the connect options * @return */ public static Uni connect(io.vertx.mutiny.core.Vertx vertx, PgConnectOptions options) { return io.smallrye.mutiny.vertx.AsyncResultUni.toUni(handler -> { __connect(vertx, options, handler); }); } /** * 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. * @param vertx the vertx instance * @param options the connect options * @return */ public static io.reactiverse.mutiny.pgclient.PgConnection connectAndAwait(io.vertx.mutiny.core.Vertx vertx, PgConnectOptions options) { return (io.reactiverse.mutiny.pgclient.PgConnection) connect(vertx, options).await().indefinitely(); } /** * Like {@link io.reactiverse.mutiny.pgclient.PgClient#connect} with options build from the environment variables. * @param vertx * @param handler */ private static void __connect(io.vertx.mutiny.core.Vertx vertx, Handler> handler) { io.reactiverse.pgclient.PgClient.connect(vertx.getDelegate(), new Handler>() { public void handle(AsyncResult ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.mutiny.pgclient.PgConnection.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); } /** * Like {@link io.reactiverse.mutiny.pgclient.PgClient#connect} with options build from the environment variables. * @param vertx * @return */ public static Uni connect(io.vertx.mutiny.core.Vertx vertx) { return io.smallrye.mutiny.vertx.AsyncResultUni.toUni(handler -> { __connect(vertx, handler); }); } /** * Like {@link io.reactiverse.mutiny.pgclient.PgClient#connect} with options build from the environment variables. * @param vertx * @return */ public static io.reactiverse.mutiny.pgclient.PgConnection connectAndAwait(io.vertx.mutiny.core.Vertx vertx) { return (io.reactiverse.mutiny.pgclient.PgConnection) connect(vertx).await().indefinitely(); } /** * Like {@link io.reactiverse.mutiny.pgclient.PgClient#connect} with options build from connectionUri. * @param vertx * @param connectionUri * @param handler */ private static void __connect(io.vertx.mutiny.core.Vertx vertx, String connectionUri, Handler> handler) { io.reactiverse.pgclient.PgClient.connect(vertx.getDelegate(), connectionUri, new Handler>() { public void handle(AsyncResult ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.mutiny.pgclient.PgConnection.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); } /** * Like {@link io.reactiverse.mutiny.pgclient.PgClient#connect} with options build from connectionUri. * @param vertx * @param connectionUri * @return */ public static Uni connect(io.vertx.mutiny.core.Vertx vertx, String connectionUri) { return io.smallrye.mutiny.vertx.AsyncResultUni.toUni(handler -> { __connect(vertx, connectionUri, handler); }); } /** * Like {@link io.reactiverse.mutiny.pgclient.PgClient#connect} with options build from connectionUri. * @param vertx * @param connectionUri * @return */ public static io.reactiverse.mutiny.pgclient.PgConnection connectAndAwait(io.vertx.mutiny.core.Vertx vertx, String connectionUri) { return (io.reactiverse.mutiny.pgclient.PgConnection) connect(vertx, connectionUri).await().indefinitely(); } /** * 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 */ private io.reactiverse.mutiny.pgclient.PgClient __query(String sql, Handler> handler) { delegate.query(sql, new Handler>() { public void handle(AsyncResult ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.mutiny.pgclient.PgRowSet.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; } /** * Execute a simple query. * @param sql the query SQL * @return a reference to this, so the API can be used fluently */ public Uni query(String sql) { return io.smallrye.mutiny.vertx.AsyncResultUni.toUni(handler -> { __query(sql, handler); }); } /** * Execute a simple query. * @param sql the query SQL * @return a reference to this, so the API can be used fluently */ public io.reactiverse.mutiny.pgclient.PgRowSet queryAndAwait(String sql) { return (io.reactiverse.mutiny.pgclient.PgRowSet) query(sql).await().indefinitely(); } /** * 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 */ private io.reactiverse.mutiny.pgclient.PgClient __preparedQuery(String sql, Handler> handler) { delegate.preparedQuery(sql, new Handler>() { public void handle(AsyncResult ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.mutiny.pgclient.PgRowSet.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; } /** * Prepare and execute a query. * @param sql the prepared query SQL * @return a reference to this, so the API can be used fluently */ public Uni preparedQuery(String sql) { return io.smallrye.mutiny.vertx.AsyncResultUni.toUni(handler -> { __preparedQuery(sql, handler); }); } /** * Prepare and execute a query. * @param sql the prepared query SQL * @return a reference to this, so the API can be used fluently */ public io.reactiverse.mutiny.pgclient.PgRowSet preparedQueryAndAwait(String sql) { return (io.reactiverse.mutiny.pgclient.PgRowSet) preparedQuery(sql).await().indefinitely(); } /** * 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 */ private io.reactiverse.mutiny.pgclient.PgClient __preparedQuery(String sql, io.reactiverse.mutiny.pgclient.Tuple arguments, Handler> handler) { delegate.preparedQuery(sql, arguments.getDelegate(), new Handler>() { public void handle(AsyncResult ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.mutiny.pgclient.PgRowSet.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; } /** * 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 Uni preparedQuery(String sql, io.reactiverse.mutiny.pgclient.Tuple arguments) { return io.smallrye.mutiny.vertx.AsyncResultUni.toUni(handler -> { __preparedQuery(sql, arguments, handler); }); } /** * 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 io.reactiverse.mutiny.pgclient.PgRowSet preparedQueryAndAwait(String sql, io.reactiverse.mutiny.pgclient.Tuple arguments) { return (io.reactiverse.mutiny.pgclient.PgRowSet) preparedQuery(sql, arguments).await().indefinitely(); } /** * 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 */ private io.reactiverse.mutiny.pgclient.PgClient __preparedBatch(String sql, List batch, Handler> handler) { delegate.preparedBatch(sql, batch.stream().map(elt -> elt.getDelegate()).collect(java.util.stream.Collectors.toList()), new Handler>() { public void handle(AsyncResult ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.reactiverse.mutiny.pgclient.PgRowSet.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; } /** * 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 Uni preparedBatch(String sql, List batch) { return io.smallrye.mutiny.vertx.AsyncResultUni.toUni(handler -> { __preparedBatch(sql, batch, handler); }); } /** * 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 io.reactiverse.mutiny.pgclient.PgRowSet preparedBatchAndAwait(String sql, List batch) { return (io.reactiverse.mutiny.pgclient.PgRowSet) preparedBatch(sql, batch).await().indefinitely(); } /** * 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; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy