Class TcpClientConnection

java.lang.Object
io.helidon.webclient.api.TcpClientConnection
All Implemented Interfaces:
ClientConnection, ReleasableResource

public class TcpClientConnection extends Object implements ClientConnection
A TCP connection that can be used by any protocol that is based on TCP. The connection supports proxying and is not attempting to cache anything.
  • Method Details

    • create

      public static TcpClientConnection create(WebClient webClient, ConnectionKey connectionKey, List<String> tcpProtocolIds, Function<TcpClientConnection,Boolean> releaseFunction, Consumer<TcpClientConnection> closeConsumer)
      Create a new TCP Connection.
      Parameters:
      webClient - webclient, may be used to create proxy connections
      connectionKey - connection key of the new connection (where and how to connect)
      tcpProtocolIds - protocol IDs for ALPN (TLS protocol negotiation)
      releaseFunction - called when releaseResource() is called, if false is returned, the connection will be closed instead kept open
      closeConsumer - called when closeResource() is called, the connection is no longer usable after this moment
      Returns:
      a new TCP connection, connect() must be called to make it available for use
    • connect

      public TcpClientConnection connect()
      Connect this connection over the network. This will resolve proxy connection, TLS negotiation (including ALPN) and return a connected connection.
      Returns:
      this connection, connected to the remote socket
    • reader

      public DataReader reader()
      Description copied from interface: ClientConnection
      Data reader providing response bytes.
      Specified by:
      reader in interface ClientConnection
      Returns:
      reader to read from this connection
    • writer

      public DataWriter writer()
      Description copied from interface: ClientConnection
      Data writer the client request writes to.
      Specified by:
      writer in interface ClientConnection
      Returns:
      writer to write to this connection
    • releaseResource

      public void releaseResource()
      Description copied from interface: ReleasableResource
      Releases the resource, and if this resource is re-usable, enabled reuse.
      Specified by:
      releaseResource in interface ReleasableResource
    • closeResource

      public void closeResource()
      Description copied from interface: ReleasableResource
      Closes the resource, we cannot use name close, as that would conflict with AutoCloseable, as we do not want to have a checked exception thrown.
      Specified by:
      closeResource in interface ReleasableResource
    • channelId

      public String channelId()
      Description copied from interface: ClientConnection
      Channel id, mostly used in logs.
      Specified by:
      channelId in interface ClientConnection
      Returns:
      id of this channel (connection)
    • readTimeout

      public void readTimeout(Duration readTimeout)
      Description copied from interface: ClientConnection
      Read timeout for this connection.
      Specified by:
      readTimeout in interface ClientConnection
      Parameters:
      readTimeout - connection read timeout
    • helidonSocket

      public HelidonSocket helidonSocket()
      Description copied from interface: ClientConnection
      Associated HelidonSocket.
      Specified by:
      helidonSocket in interface ClientConnection
      Returns:
      socket of this connection
    • isConnected

      public boolean isConnected()