Class PgSubscriber
- java.lang.Object
-
- io.vertx.mutiny.pgclient.pubsub.PgSubscriber
-
public class PgSubscriber extends Object
A class for managing subscriptions usingLISTEN/UNLISTENto Postgres channels. The subscriber manages a single connection to Postgres. NOTE: This class has been automatically generated from theoriginalnon Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<PgSubscriber>__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description PgSubscriber(io.vertx.pgclient.pubsub.PgSubscriber delegate)PgSubscriber(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PgConnectionactualConnection()PgChannelchannel(String name)io.smallrye.mutiny.Uni<Void>close()Close the subscriber, the retry policy will not be invoked.VoidcloseAndAwait()Blocking variant ofclose().voidcloseAndForget()Variant ofclose()that ignores the result of the operation.booleanclosed()PgSubscribercloseHandler(Runnable handler)io.smallrye.mutiny.Uni<Void>connect()Connect the subscriber to Postgres.VoidconnectAndAwait()Blocking variant ofconnect().PgSubscriberconnectAndForget()Variant ofconnect()that ignores the result of the operation.booleanequals(Object o)io.vertx.pgclient.pubsub.PgSubscribergetDelegate()inthashCode()static PgSubscribernewInstance(io.vertx.pgclient.pubsub.PgSubscriber arg)PgSubscriberreconnectPolicy(Function<Integer,Long> policy)static PgSubscribersubscriber(Vertx vertx, io.vertx.pgclient.PgConnectOptions options)StringtoString()
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<PgSubscriber> __TYPE_ARG
-
-
Constructor Detail
-
PgSubscriber
public PgSubscriber(io.vertx.pgclient.pubsub.PgSubscriber delegate)
-
PgSubscriber
public PgSubscriber(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.pgclient.pubsub.PgSubscriber getDelegate()
-
subscriber
public static PgSubscriber subscriber(Vertx vertx, io.vertx.pgclient.PgConnectOptions options)
- Parameters:
vertx- the vertx instanceoptions- 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 == 63characters, and prepared as a quoted identifier without unicode escape sequence support for use inLISTEN/UNLISTENcommands. Examples of channel names and correspondingNOTIFYcommands:- when
name == "the_channel":NOTIFY the_channel, 'msg',NOTIFY The_Channel, 'msg', orNOTIFY "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
- when
- Returns:
- the channel
-
connect
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
unifiring the result of the operation when completed, or a failure if the operation failed.
-
connectAndAwait
public Void connectAndAwait()
Blocking variant ofconnect().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 ofconnect()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 fromconnect()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
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
unifiring the result of the operation when completed, or a failure if the operation failed.
-
closeAndAwait
public Void closeAndAwait()
Blocking variant ofclose().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()
-
newInstance
public static PgSubscriber newInstance(io.vertx.pgclient.pubsub.PgSubscriber arg)
-
-