Class PgSubscriber

java.lang.Object
io.vertx.mutiny.pgclient.pubsub.PgSubscriber
All Implemented Interfaces:
MutinyDelegate

public class PgSubscriber extends Object implements MutinyDelegate
A class for managing subscriptions using LISTEN/UNLISTEN to Postgres channels.

The subscriber manages a single connection to Postgres.

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

  • Field Details

  • Constructor Details

    • PgSubscriber

      public PgSubscriber(io.vertx.pgclient.pubsub.PgSubscriber delegate)
    • PgSubscriber

      public PgSubscriber(Object delegate)
  • Method Details

    • getDelegate

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

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

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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • subscriber

      public static PgSubscriber subscriber(Vertx vertx, io.vertx.pgclient.PgConnectOptions options)
      Parameters:
      vertx - the vertx instance
      options - the connect options
      Returns:
      the subscriber
    • channel

      public PgChannel channel(String name)
      Parameters:
      name - the channel name

      This will be the name of the channel exactly as held by Postgres for sending notifications. Internally this name will be truncated to the Postgres identifier maxiumum length of (NAMEDATALEN = 64) - 1 == 63 characters, and prepared as a quoted identifier without unicode escape sequence support for use in LISTEN/UNLISTEN commands. Examples of channel names and corresponding NOTIFY commands:

      • when name == "the_channel": NOTIFY the_channel, 'msg', NOTIFY The_Channel, 'msg', or NOTIFY "the_channel", 'msg' succeed in delivering a message to the created channel
      • when name == "The_Channel": NOTIFY "The_Channel", 'msg', succeeds in delivering a message to the created channel
      Returns:
      the channel
    • connect

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> connect()
      Connect the subscriber to Postgres.

      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.
    • connectAndAwait

      public Void connectAndAwait()
      Blocking variant of connect().

      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.
    • connectAndForget

      public PgSubscriber connectAndForget()
      Variant of connect() that ignores the result of the operation.

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

      Returns:
      the instance of PgSubscriber to chain method calls.
    • reconnectPolicy

      public PgSubscriber reconnectPolicy(Function<Integer,Long> policy)
      Parameters:
      policy - the policy to set
      Returns:
      a reference to this, so the API can be used fluently
    • closeHandler

      public PgSubscriber closeHandler(Runnable handler)
      Parameters:
      handler - the handler
      Returns:
    • actualConnection

      public PgConnection actualConnection()
      Returns:
      the actual connection to Postgres, it might be null
    • closed

      public boolean closed()
      Returns:
      whether the subscriber is closed
    • close

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> close()
      Close the subscriber, the retry policy will not be invoked.

      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.
    • closeAndAwait

      public Void closeAndAwait()
      Blocking variant of close().

      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.
    • closeAndForget

      public void closeAndForget()
      Variant of close() that ignores the result of the operation.

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

    • newInstance

      public static PgSubscriber newInstance(io.vertx.pgclient.pubsub.PgSubscriber arg)