Class 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 the original non Mutiny-ified interface using Vert.x codegen.

    • 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:
        getDelegate in interface Measured
      • hashCode

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

        public boolean isMetricsEnabled()
        Specified by:
        isMetricsEnabled in interface Measured
        Returns:
        true if metrics are enabled
      • connect

        public io.smallrye.mutiny.Uni<NetSocket> connect​(int port,
                                                         String host)
        Open a connection to a server at the specific port and host.

        host can be a valid host name or IP address. The connect is done asynchronously and on success, a NetSocket instance is supplied via the connectHandler instance

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

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

        public NetSocket connectAndAwait​(int port,
                                         String host)
        Blocking variant of connect(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 port
        host - the host
        Returns:
        the NetSocket instance produced by the operation.
      • connectAndForget

        public NetClient connectAndForget​(int port,
                                          String host)
        Variant of connect(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 from connect(int,String) but you don't need to compose it with other operations.

        Parameters:
        port - the port
        host - the host
        Returns:
        the instance of NetClient to chain method calls.
      • connect

        public io.smallrye.mutiny.Uni<NetSocket> connect​(int port,
                                                         String host,
                                                         String serverName)
        Open a connection to a server at the specific port and host.

        host can be a valid host name or IP address. The connect is done asynchronously and on success, a NetSocket instance is supplied via the connectHandler instance

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

        Parameters:
        port - the port
        host - the host
        serverName - the SNI server name
        Returns:
        the uni firing 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 of connect(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 port
        host - the host
        serverName - the SNI server name
        Returns:
        the NetSocket instance produced by the operation.
      • connectAndForget

        public NetClient connectAndForget​(int port,
                                          String host,
                                          String serverName)
        Variant of connect(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 from connect(int,String,String) but you don't need to compose it with other operations.

        Parameters:
        port - the port
        host - the host
        serverName - the SNI server name
        Returns:
        the instance of NetClient to chain method calls.
      • connect

        public io.smallrye.mutiny.Uni<NetSocket> connect​(SocketAddress remoteAddress)
        Open a connection to a server at the specific remoteAddress.

        The connect is done asynchronously and on success, a NetSocket instance is supplied via the connectHandler instance

        Unlike 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 uni firing the result of the operation when completed, or a failure if the operation failed.
      • connectAndAwait

        public NetSocket connectAndAwait​(SocketAddress remoteAddress)
        Blocking variant of connect(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.
      • connect

        public io.smallrye.mutiny.Uni<NetSocket> connect​(SocketAddress remoteAddress,
                                                         String serverName)
        Open a connection to a server at the specific remoteAddress.

        The connect is done asynchronously and on success, a NetSocket instance is supplied via the connectHandler instance

        Unlike 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
        serverName - the SNI server name
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • connectAndAwait

        public NetSocket connectAndAwait​(SocketAddress remoteAddress,
                                         String serverName)
        Blocking variant of connect(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 address
        serverName - the SNI server name
        Returns:
        the NetSocket instance produced by the operation.
      • close

        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 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 NetClient newInstance​(io.vertx.core.net.NetClient arg)