Class NetClient
- java.lang.Object
-
- io.vertx.mutiny.core.net.NetClient
-
- All Implemented Interfaces:
Measured
public class NetClient extends Object implements Measured
A TCP client.Multiple connections to different servers can be made using the same instance.
This client supports a configurable number of connection attempts and a configurable delay between attempts.
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<NetClient>__TYPE_ARG
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description io.smallrye.mutiny.Uni<Void>close()Close the client.VoidcloseAndAwait()Blocking variant ofclose().voidcloseAndForget()Variant ofclose()that ignores the result of the operation.io.smallrye.mutiny.Uni<NetSocket>connect(int port, String host)Open a connection to a server at the specificportandhost.io.smallrye.mutiny.Uni<NetSocket>connect(int port, String host, String serverName)Open a connection to a server at the specificportandhost.io.smallrye.mutiny.Uni<NetSocket>connect(SocketAddress remoteAddress)Open a connection to a server at the specificremoteAddress.io.smallrye.mutiny.Uni<NetSocket>connect(SocketAddress remoteAddress, String serverName)Open a connection to a server at the specificremoteAddress.NetSocketconnectAndAwait(int port, String host)Blocking variant ofconnect(int,String).NetSocketconnectAndAwait(int port, String host, String serverName)Blocking variant ofconnect(int,String,String).NetSocketconnectAndAwait(SocketAddress remoteAddress)Blocking variant ofconnect(io.vertx.mutiny.core.net.SocketAddress).NetSocketconnectAndAwait(SocketAddress remoteAddress, String serverName)Blocking variant ofconnect(io.vertx.mutiny.core.net.SocketAddress,String).NetClientconnectAndForget(int port, String host)Variant ofconnect(int,String)that ignores the result of the operation.NetClientconnectAndForget(int port, String host, String serverName)Variant ofconnect(int,String,String)that ignores the result of the operation.NetClientconnectAndForget(SocketAddress remoteAddress)Variant ofconnect(io.vertx.mutiny.core.net.SocketAddress)that ignores the result of the operation.NetClientconnectAndForget(SocketAddress remoteAddress, String serverName)Variant ofconnect(io.vertx.mutiny.core.net.SocketAddress,String)that ignores the result of the operation.booleanequals(Object o)io.vertx.core.net.NetClientgetDelegate()inthashCode()booleanisMetricsEnabled()static NetClientnewInstance(io.vertx.core.net.NetClient arg)StringtoString()
-
-
-
Constructor Detail
-
NetClient
public NetClient(io.vertx.core.net.NetClient delegate)
-
NetClient
public NetClient(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.core.net.NetClient getDelegate()
- Specified by:
getDelegatein interfaceMeasured
-
isMetricsEnabled
public boolean isMetricsEnabled()
- Specified by:
isMetricsEnabledin interfaceMeasured- Returns:
trueif metrics are enabled
-
connect
@CheckReturnValue public io.smallrye.mutiny.Uni<NetSocket> connect(int port, String host)
Open a connection to a server at the specificportandhost.hostcan be a valid host name or IP address. The connect is done asynchronously and on success, aNetSocketinstance is supplied via theconnectHandlerinstanceUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
port- the porthost- the host- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
connectAndAwait
public NetSocket connectAndAwait(int port, String host)
Blocking variant ofconnect(int,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:
port- the porthost- the host- Returns:
- the NetSocket instance produced by the operation.
-
connectAndForget
public NetClient connectAndForget(int port, String host)
Variant ofconnect(int,String)that ignores the result of the operation.This method subscribes on the result of
connect(int,String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromconnect(int,String)but you don't need to compose it with other operations.- Parameters:
port- the porthost- the host- Returns:
- the instance of NetClient to chain method calls.
-
connect
@CheckReturnValue public io.smallrye.mutiny.Uni<NetSocket> connect(int port, String host, String serverName)
Open a connection to a server at the specificportandhost.hostcan be a valid host name or IP address. The connect is done asynchronously and on success, aNetSocketinstance is supplied via theconnectHandlerinstanceUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
port- the porthost- the hostserverName- the SNI server name- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
connectAndAwait
public NetSocket connectAndAwait(int port, String host, String serverName)
Blocking variant ofconnect(int,String,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:
port- the porthost- the hostserverName- the SNI server name- Returns:
- the NetSocket instance produced by the operation.
-
connectAndForget
public NetClient connectAndForget(int port, String host, String serverName)
Variant ofconnect(int,String,String)that ignores the result of the operation.This method subscribes on the result of
connect(int,String,String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromconnect(int,String,String)but you don't need to compose it with other operations.- Parameters:
port- the porthost- the hostserverName- the SNI server name- Returns:
- the instance of NetClient to chain method calls.
-
connect
@CheckReturnValue public io.smallrye.mutiny.Uni<NetSocket> connect(SocketAddress remoteAddress)
Open a connection to a server at the specificremoteAddress.The connect is done asynchronously and on success, a
NetSocketinstance is supplied via theconnectHandlerinstanceUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
remoteAddress- the remote address- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
connectAndAwait
public NetSocket connectAndAwait(SocketAddress remoteAddress)
Blocking variant ofconnect(io.vertx.mutiny.core.net.SocketAddress).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:
remoteAddress- the remote address- Returns:
- the NetSocket instance produced by the operation.
-
connectAndForget
public NetClient connectAndForget(SocketAddress remoteAddress)
Variant ofconnect(io.vertx.mutiny.core.net.SocketAddress)that ignores the result of the operation.This method subscribes on the result of
connect(io.vertx.mutiny.core.net.SocketAddress), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromconnect(io.vertx.mutiny.core.net.SocketAddress)but you don't need to compose it with other operations.- Parameters:
remoteAddress- the remote address- Returns:
- the instance of NetClient to chain method calls.
-
connect
@CheckReturnValue public io.smallrye.mutiny.Uni<NetSocket> connect(SocketAddress remoteAddress, String serverName)
Open a connection to a server at the specificremoteAddress.The connect is done asynchronously and on success, a
NetSocketinstance is supplied via theconnectHandlerinstanceUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
remoteAddress- the remote addressserverName- the SNI server name- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
connectAndAwait
public NetSocket connectAndAwait(SocketAddress remoteAddress, String serverName)
Blocking variant ofconnect(io.vertx.mutiny.core.net.SocketAddress,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:
remoteAddress- the remote addressserverName- the SNI server name- Returns:
- the NetSocket instance produced by the operation.
-
connectAndForget
public NetClient connectAndForget(SocketAddress remoteAddress, String serverName)
Variant ofconnect(io.vertx.mutiny.core.net.SocketAddress,String)that ignores the result of the operation.This method subscribes on the result of
connect(io.vertx.mutiny.core.net.SocketAddress,String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromconnect(io.vertx.mutiny.core.net.SocketAddress,String)but you don't need to compose it with other operations.- Parameters:
remoteAddress- the remote addressserverName- the SNI server name- Returns:
- the instance of NetClient to chain method calls.
-
close
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> close()
Close the client.Any sockets which have not been closed manually will be closed here. The close is asynchronous and may not complete until some time after the method has returned.
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 NetClient newInstance(io.vertx.core.net.NetClient arg)
-
-