Class PgChannel

java.lang.Object
io.vertx.mutiny.pgclient.pubsub.PgChannel
All Implemented Interfaces:
MutinyDelegate, ReadStream<String>, StreamBase

public class PgChannel extends Object implements ReadStream<String>, MutinyDelegate
A channel to Postgres that tracks the subscription to a given Postgres channel using the LISTEN/UNLISTEN commands.

When paused the channel discards the messages.

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

See Also:
  • PgChannel
  • Field Details

  • Constructor Details

    • PgChannel

      public PgChannel(io.vertx.pgclient.pubsub.PgChannel delegate)
      Create a new instance of PgChannel delegating to the given (non-null) instance of PgChannel.
    • PgChannel

      public PgChannel(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.pgclient.pubsub.PgChannel getDelegate()
      Get the delegate instance.

      This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.

      Specified by:
      getDelegate in interface MutinyDelegate
      Specified by:
      getDelegate in interface ReadStream<String>
      Specified by:
      getDelegate in interface StreamBase
      Returns:
      the delegate instance
    • pipeTo

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<String> dst)
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Specified by:
      pipeTo in interface ReadStream<String>
      Parameters:
      dst - the destination write stream
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • io.vertx.pgclient.pubsub.PgChannel#pipeTo(WriteStream)
    • pipeToAndAwait

      public void pipeToAndAwait(WriteStream<String> dst)
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely 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:
      dst - the destination write stream
      See Also:
      • io.vertx.pgclient.pubsub.PgChannel#pipeTo(WriteStream)
    • pipeToAndForget

      public PgChannel pipeToAndForget(WriteStream<String> dst)
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      dst - the destination write stream
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • io.vertx.pgclient.pubsub.PgChannel#pipeTo(WriteStream)
    • subscribeHandler

      public PgChannel subscribeHandler(Runnable handler)
      Set an handler called when the the channel get subscribed.
      Parameters:
      handler - the handler
      Returns:
      a reference to this, so the API can be used fluently
    • handler

      public PgChannel handler(Consumer<String> handler)
      Set or unset an handler to be called when a the channel is notified by Postgres.

      • when the handler is set, the subscriber sends a LISTEN command if needed
      • when the handler is unset, the subscriber sends a UNLISTEN command if needed
      Specified by:
      handler in interface ReadStream<String>
      Parameters:
      handler - the handler
      Returns:
      a reference to this, so the API can be used fluently
    • pause

      public PgChannel pause()
      Pause the channel, all notifications are discarded.
      Specified by:
      pause in interface ReadStream<String>
      Returns:
      a reference to this, so the API can be used fluently
    • resume

      public PgChannel resume()
      Resume the channel.
      Specified by:
      resume in interface ReadStream<String>
      Returns:
      a reference to this, so the API can be used fluently
    • endHandler

      public PgChannel endHandler(Runnable endHandler)
      Set an handler to be called when no more notifications will be received.
      Specified by:
      endHandler in interface ReadStream<String>
      Parameters:
      endHandler - the handler
      Returns:
      a reference to this, so the API can be used fluently
    • exceptionHandler

      public PgChannel exceptionHandler(Consumer<Throwable> handler)
      Inherited from ReadStream#exceptionHandler(Handler) but this one is a no-op.
      Specified by:
      exceptionHandler in interface ReadStream<String>
      Specified by:
      exceptionHandler in interface StreamBase
      Parameters:
      handler - the exception handler. Can be null.
      Returns:
      a reference to this, so the API can be used fluently
    • fetch

      public PgChannel fetch(long amount)
      Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.
      Specified by:
      fetch in interface ReadStream<String>
      Returns:
      a reference to this, so the API can be used fluently
      Throws:
      when - the amount is a negative value
    • pipe

      public Pipe<String> pipe()
      Pause this stream and return a Pipe to transfer the elements of this stream to a destination WriteStream.

      The stream will be resumed when the pipe will be wired to a WriteStream.

      Specified by:
      pipe in interface ReadStream<String>
      Returns:
      a pipe
    • newInstance

      public static PgChannel newInstance(io.vertx.pgclient.pubsub.PgChannel delegate)
      Creates a new instance of the PgChannel.
    • hashCode

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

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

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

      @CheckReturnValue public io.smallrye.mutiny.Multi<String> toMulti()
    • toBlockingIterable

      public Iterable<String> toBlockingIterable()
    • toBlockingStream

      public Stream<String> toBlockingStream()