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

io.reactiverse.pgclient.PgConnection Maven / Gradle / Ivy

There is a newer version: 0.11.4
Show newest version
/*
 * Copyright (C) 2017 Julien Viet
 *
 * Licensed 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.pgclient;

import io.vertx.codegen.annotations.Fluent;
import io.vertx.codegen.annotations.GenIgnore;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.*;

import java.util.List;
import java.util.stream.Collector;

/**
 * A connection to Postgres.
 *
 * @author Julien Viet
 * @author Emad Alblueshi
 */
@VertxGen
public interface PgConnection extends PgClient {

  /**
   * Create a prepared query.
   *
   * @param sql the sql
   * @param handler the handler notified with the prepared query asynchronously
   */
  @Fluent
  PgConnection prepare(String sql, Handler> handler);

  /**
   * Set an handler called with connection errors.
   *
   * @param handler the handler
   * @return a reference to this, so the API can be used fluently
   */
  @Fluent
  PgConnection exceptionHandler(Handler handler);

  /**
   * Set an handler called when the connection is closed.
   *
   * @param handler the handler
   * @return a reference to this, so the API can be used fluently
   */
  @Fluent
  PgConnection closeHandler(Handler handler);

  /**
   * Begin a transaction and returns a {@link PgTransaction} for controlling and tracking
   * this transaction.
   * 

* When the connection is explicitely closed, any inflight transaction is rollbacked. * * @return the transaction instance */ PgTransaction begin(); /** * Set an handler called when the connection receives notification on a channel. *

* The handler is called with the {@link PgNotification} and has access to the channel name * and the notification payload. * * @param handler the handler * @return the transaction instance */ @Fluent PgConnection notificationHandler(Handler handler); /** * @return whether the connection uses SSL */ boolean isSSL(); /** * Close the current connection after all the pending commands have been processed. */ void close(); @Override PgConnection preparedQuery(String sql, Handler> handler); @Override @GenIgnore PgConnection preparedQuery(String sql, Collector collector, Handler>> handler); @Override PgConnection query(String sql, Handler> handler); @Override @GenIgnore PgConnection query(String sql, Collector collector, Handler>> handler); @Override PgConnection preparedQuery(String sql, Tuple arguments, Handler> handler); @Override @GenIgnore PgConnection preparedQuery(String sql, Tuple arguments, Collector collector, Handler>> handler); @Override PgConnection preparedBatch(String sql, List batch, Handler> handler); @Override @GenIgnore PgConnection preparedBatch(String sql, List batch, Collector collector, Handler>> handler); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy