Class PgConnection

All Implemented Interfaces:
MutinyDelegate

public class PgConnection extends SqlConnection implements MutinyDelegate
A connection to Postgres.

The connection object supports all the operations defined in the interface, it also provides additional support:

  • Notification
  • Request Cancellation

NOTE: This class has been automatically generated from the original non Mutiny-ified interface using Vert.x codegen.

  • Field Details

  • Constructor Details

    • PgConnection

      public PgConnection(io.vertx.pgclient.PgConnection delegate)
    • PgConnection

      public PgConnection(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.pgclient.PgConnection getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Overrides:
      getDelegate in class SqlConnection
      Returns:
      the delegate used by this Mutiny object of generated type
    • toString

      public String toString()
      Overrides:
      toString in class SqlConnection
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class SqlConnection
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class SqlConnection
    • connect

      @CheckReturnValue public static io.smallrye.mutiny.Uni<PgConnection> connect(Vertx vertx, io.vertx.pgclient.PgConnectOptions options)
      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.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      vertx - the vertx instance
      options - the connect options
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • connectAndAwait

      public static PgConnection connectAndAwait(Vertx vertx, io.vertx.pgclient.PgConnectOptions options)
      Blocking variant of connect(io.vertx.mutiny.core.Vertx,PgConnectOptions).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      vertx - the vertx instance
      options - the connect options
      Returns:
      the PgConnection instance produced by the operation.
    • connectAndForget

      public static void connectAndForget(Vertx vertx, io.vertx.pgclient.PgConnectOptions options)
      Variant of connect(io.vertx.mutiny.core.Vertx,PgConnectOptions) that ignores the result of the operation.

      This method subscribes on the result of connect(io.vertx.mutiny.core.Vertx,PgConnectOptions), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from connect(io.vertx.mutiny.core.Vertx,PgConnectOptions) but you don't need to compose it with other operations.

      Parameters:
      vertx - the vertx instance
      options - the connect options
    • connect

      @CheckReturnValue public static io.smallrye.mutiny.Uni<PgConnection> connect(Vertx vertx)
      Like connect(io.vertx.mutiny.core.Vertx, io.vertx.pgclient.PgConnectOptions) with options build from the environment variables.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      vertx -
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • connectAndAwait

      public static PgConnection connectAndAwait(Vertx vertx)
      Blocking variant of connect(io.vertx.mutiny.core.Vertx).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      vertx -
      Returns:
      the PgConnection instance produced by the operation.
    • connectAndForget

      public static void connectAndForget(Vertx vertx)
      Variant of connect(io.vertx.mutiny.core.Vertx) that ignores the result of the operation.

      This method subscribes on the result of connect(io.vertx.mutiny.core.Vertx), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from connect(io.vertx.mutiny.core.Vertx) but you don't need to compose it with other operations.

      Parameters:
      vertx -
    • connect

      @CheckReturnValue public static io.smallrye.mutiny.Uni<PgConnection> connect(Vertx vertx, String connectionUri)
      Like connect(io.vertx.mutiny.core.Vertx, io.vertx.pgclient.PgConnectOptions) with options build from connectionUri.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      vertx -
      connectionUri -
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • connectAndAwait

      public static PgConnection connectAndAwait(Vertx vertx, String connectionUri)
      Blocking variant of connect(io.vertx.mutiny.core.Vertx,String).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      vertx -
      connectionUri -
      Returns:
      the PgConnection instance produced by the operation.
    • connectAndForget

      public static void connectAndForget(Vertx vertx, String connectionUri)
      Variant of connect(io.vertx.mutiny.core.Vertx,String) that ignores the result of the operation.

      This method subscribes on the result of connect(io.vertx.mutiny.core.Vertx,String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from connect(io.vertx.mutiny.core.Vertx,String) but you don't need to compose it with other operations.

      Parameters:
      vertx -
      connectionUri -
    • notificationHandler

      public PgConnection notificationHandler(Consumer<io.vertx.pgclient.PgNotification> handler)
      Parameters:
      handler - the handler
      Returns:
    • noticeHandler

      public PgConnection noticeHandler(Consumer<io.vertx.pgclient.PgNotice> handler)
      Parameters:
      handler -
      Returns:
    • cancelRequest

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> cancelRequest()
      Send a request cancellation message to tell the server to cancel processing request in this connection.
      Note: Use this with caution because the cancellation signal may or may not have any effect.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • cancelRequestAndAwait

      public Void cancelRequestAndAwait()
      Blocking variant of cancelRequest().

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      the Void instance produced by the operation.
    • cancelRequestAndForget

      public void cancelRequestAndForget()
      Variant of cancelRequest() that ignores the result of the operation.

      This method subscribes on the result of cancelRequest(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from cancelRequest() but you don't need to compose it with other operations.

    • processId

      public int processId()
      Returns:
      The process ID of the target backend
    • secretKey

      public int secretKey()
      Returns:
      The secret key for the target backend
    • prepare

      @CheckReturnValue public io.smallrye.mutiny.Uni<PreparedStatement> prepare(String sql)

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Overrides:
      prepare in class SqlConnection
      Parameters:
      sql -
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • prepareAndAwait

      public PreparedStatement prepareAndAwait(String sql)
      Blocking variant of prepare(String).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Overrides:
      prepareAndAwait in class SqlConnection
      Parameters:
      sql -
      Returns:
      the PreparedStatement instance produced by the operation.
    • prepareAndForget

      public PgConnection prepareAndForget(String sql)
      Variant of prepare(String) that ignores the result of the operation.

      This method subscribes on the result of prepare(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from prepare(String) but you don't need to compose it with other operations.

      Overrides:
      prepareAndForget in class SqlConnection
      Parameters:
      sql -
      Returns:
      the instance of PgConnection to chain method calls.
    • exceptionHandler

      public PgConnection exceptionHandler(Consumer<Throwable> handler)
      Overrides:
      exceptionHandler in class SqlConnection
      Parameters:
      handler -
      Returns:
    • closeHandler

      public PgConnection closeHandler(Runnable handler)
      Overrides:
      closeHandler in class SqlConnection
      Parameters:
      handler -
      Returns:
    • cast

      public static PgConnection cast(SqlConnection sqlConnection)
      Parameters:
      sqlConnection - the connection to cast
      Returns:
      a instance
    • newInstance

      public static PgConnection newInstance(io.vertx.pgclient.PgConnection arg)