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

com.julienviet.reactivex.pgclient.PgPool Maven / Gradle / Ivy

There is a newer version: 0.6.0
Show newest version
/*
 * 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 com.julienviet.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 java.util.List;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;

/**
 * A pool of connection.
 *
 * 

* NOTE: This class has been automatically generated from the {@link com.julienviet.pgclient.PgPool original} non RX-ified interface using Vert.x codegen. */ @io.vertx.lang.reactivex.RxGen(com.julienviet.pgclient.PgPool.class) public class PgPool extends 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; PgPool that = (PgPool) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final io.vertx.lang.reactivex.TypeArg __TYPE_ARG = new io.vertx.lang.reactivex.TypeArg<>( obj -> new PgPool((com.julienviet.pgclient.PgPool) obj), PgPool::getDelegate ); private final com.julienviet.pgclient.PgPool delegate; public PgPool(com.julienviet.pgclient.PgPool delegate) { super(delegate); this.delegate = delegate; } public com.julienviet.pgclient.PgPool getDelegate() { return delegate; } public PgPool 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(PgResult.newInstance(ar.result(), com.julienviet.reactivex.pgclient.Row.__TYPE_ARG))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; } public Single> rxPreparedQuery(String sql) { return new io.vertx.reactivex.core.impl.AsyncResultSingle>(handler -> { preparedQuery(sql, handler); }); } public PgPool 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(PgResult.newInstance(ar.result(), com.julienviet.reactivex.pgclient.Row.__TYPE_ARG))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; } public Single> rxQuery(String sql) { return new io.vertx.reactivex.core.impl.AsyncResultSingle>(handler -> { query(sql, handler); }); } public PgPool preparedQuery(String sql, 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(PgResult.newInstance(ar.result(), com.julienviet.reactivex.pgclient.Row.__TYPE_ARG))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; } public Single> rxPreparedQuery(String sql, Tuple arguments) { return new io.vertx.reactivex.core.impl.AsyncResultSingle>(handler -> { preparedQuery(sql, arguments, handler); }); } public PgPool 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(PgResult.newInstance(ar.result(), com.julienviet.reactivex.pgclient.Row.__TYPE_ARG))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; } public Single> rxPreparedBatch(String sql, List batch) { return new io.vertx.reactivex.core.impl.AsyncResultSingle>(handler -> { preparedBatch(sql, batch, handler); }); } /** * Get a connection from the pool. * @param handler the handler that will get the connection result */ public void getConnection(Handler> handler) { delegate.getConnection(new Handler>() { public void handle(AsyncResult ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(PgConnection.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); } /** * Get a connection from the pool. * @return */ public Single rxGetConnection() { return new io.vertx.reactivex.core.impl.AsyncResultSingle(handler -> { getConnection(handler); }); } /** * Close the pool and release the associated resources. */ public void close() { delegate.close(); } public static PgPool newInstance(com.julienviet.pgclient.PgPool arg) { return arg != null ? new PgPool(arg) : null; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy