Class ClientConnectionTarget

java.lang.Object
io.helidon.webclient.api.ClientConnectionTarget

public final class ClientConnectionTarget extends Object
Logical WebClient connection target selected after request services have finalized the URI and headers.

This value is safe to use as a cache key. A configured IP-based no-proxy rule retains the address that selected the direct route so the physical connection cannot use a different DNS answer. That per-acquisition evidence does not participate in target equality or hashing.

  • Method Details

    • lookupKey

      public static ClientConnectionTarget.LookupKey lookupKey(ConnectionKey connectionKey, ClientUri uri, ClientRequestHeaders headers)
      Create a DNS-free cache lookup key from a final request URI and headers.
      Parameters:
      connectionKey - connection policy and TLS identity
      uri - final request URI
      headers - final request headers
      Returns:
      target lookup key
    • lookupKey

      public static ClientConnectionTarget.LookupKey lookupKey(ConnectionKey connectionKey, String scheme)
      Create a DNS-free cache lookup key using the connection-key origin.
      Parameters:
      connectionKey - connection policy and TLS identity
      scheme - origin scheme
      Returns:
      target lookup key
    • create

      public static ClientConnectionTarget create(ClientConnectionTarget.LookupKey lookupKey)
      Create a logical connection target from a cache lookup key.

      This selects the effective proxy route and may resolve DNS when configured IP-based no-proxy rules require it.

      Parameters:
      lookupKey - target lookup key
      Returns:
      logical connection target
    • create

      public static ClientConnectionTarget create(ConnectionKey connectionKey, ClientUri uri, ClientRequestHeaders headers)
      Create a logical IP connection target from a final request URI and headers.
      Parameters:
      connectionKey - connection policy and TLS identity
      uri - final request URI
      headers - final request headers
      Returns:
      logical connection target
    • create

      public static ClientConnectionTarget create(ConnectionKey connectionKey, ClientUri uri, ClientRequestHeaders headers, ProxyRoute selectedProxyRoute)
      Create a logical IP connection target using an already-selected proxy route.
      Parameters:
      connectionKey - connection policy and TLS identity
      uri - final request URI
      headers - final request headers
      selectedProxyRoute - selected proxy route
      Returns:
      logical connection target
    • create

      public static ClientConnectionTarget create(ConnectionKey connectionKey, String scheme, UriAuthority originAuthority)
      Create a logical IP connection target from an already-normalized origin.
      Parameters:
      connectionKey - connection policy and TLS identity
      scheme - origin scheme
      originAuthority - normalized effective origin authority
      Returns:
      logical connection target
    • create

      public static ClientConnectionTarget create(ConnectionKey connectionKey, String scheme)
      Create a logical IP connection target using the connection-key origin.
      Parameters:
      connectionKey - connection policy and TLS identity
      scheme - origin scheme
      Returns:
      logical connection target
    • create

      public static ClientConnectionTarget create(ConnectionKey connectionKey, String scheme, UriAuthority originAuthority, ProxyRoute proxyRoute)
      Create a logical target from an already-normalized origin and selected route.
      Parameters:
      connectionKey - connection policy and TLS identity
      scheme - origin scheme
      originAuthority - normalized effective origin authority
      proxyRoute - previously selected proxy route
      Returns:
      logical connection target
    • create

      public static ClientConnectionTarget create(ConnectionKey connectionKey, String scheme, ProxyRoute proxyRoute)
      Create a logical target using the connection-key origin and a selected route.
      Parameters:
      connectionKey - connection policy and TLS identity
      scheme - origin scheme
      proxyRoute - previously selected proxy route
      Returns:
      logical connection target
    • create

      public static ClientConnectionTarget create(ConnectionKey connectionKey, String scheme, UriAuthority originAuthority, ProxyRoute proxyRoute, long tlsGeneration)
      Create a logical target from an already-normalized origin and selected route.
      Parameters:
      connectionKey - connection policy and TLS identity
      scheme - origin scheme
      originAuthority - normalized effective origin authority
      proxyRoute - previously selected proxy route
      tlsGeneration - captured TLS reload generation
      Returns:
      logical connection target
    • create

      public static ClientConnectionTarget create(ConnectionKey connectionKey, String scheme, UriAuthority originAuthority, ProxyRoute proxyRoute, InetSocketAddress localAddress, long tlsGeneration)
      Recreate a logical target from an already-selected route and captured generations.
      Parameters:
      connectionKey - connection policy and TLS identity
      scheme - origin scheme
      originAuthority - normalized effective origin authority
      proxyRoute - previously selected proxy route
      localAddress - local bind address
      tlsGeneration - captured TLS reload generation
      Returns:
      logical connection target
    • createUnixDomainSocket

      public static ClientConnectionTarget createUnixDomainSocket(ConnectionKey connectionKey, ClientUri uri, ClientRequestHeaders headers, UnixDomainSocketAddress address)
      Create a logical Unix-domain-socket target.
      Parameters:
      connectionKey - connection policy and TLS identity
      uri - final request URI
      headers - final request headers
      address - Unix-domain-socket address
      Returns:
      logical connection target
    • connectionKey

      public ConnectionKey connectionKey()
      Existing connection policy and TLS identity.
      Returns:
      connection key
    • scheme

      public String scheme()
      Normalized origin scheme.
      Returns:
      origin scheme
    • originAuthority

      public UriAuthority originAuthority()
      Normalized effective HTTP origin authority.
      Returns:
      origin authority
    • proxyRoute

      public ProxyRoute proxyRoute()
      Effective proxy route selected for this target.
      Returns:
      effective proxy route
    • transportAddress

      public Optional<SocketAddress> transportAddress()
      Physical non-IP transport override.
      Returns:
      transport address, empty for an IP target
    • localAddress

      public Optional<InetSocketAddress> localAddress()
      Requested local bind address.
      Returns:
      local bind address, empty for the ordinary wildcard bind
    • tlsGeneration

      public long tlsGeneration()
      Captured TLS reload generation.
      Returns:
      TLS generation
    • lookupKey

      Create a cache lookup key for this target without retaining its selected proxy route.
      Returns:
      target lookup key
    • currentTlsGeneration

      public boolean currentTlsGeneration()
      Whether this target still represents the current TLS reload generation.
      Returns:
      whether the TLS generation is current
    • routeMatches

      public static boolean routeMatches(ConnectionKey connectionKey, String scheme, ProxyRoute proxyRoute)
      Whether a retained route was selected for the supplied logical target and proxy policy.
      Parameters:
      connectionKey - connection policy and target tuple
      scheme - logical target scheme
      proxyRoute - retained route
      Returns:
      whether the route belongs to and matches the target
    • matchingRoute

      public static Optional<ProxyRoute> matchingRoute(ClientConnection connection, ConnectionKey connectionKey, ClientUri uri, ClientRequestHeaders headers)
      Match an explicit TCP connection to a fully finalized logical target.
      Parameters:
      connection - explicit connection
      connectionKey - finalized connection identity
      uri - finalized request URI
      headers - finalized request headers
      Returns:
      the connection's route when its complete logical target matches
    • resolve

      public ResolvedClientTarget resolve()
      Resolve a direct or proxied physical attempt for the connection-key host and port.
      Returns:
      resolved target
    • resolve

      public ResolvedClientTarget resolve(String routeHost, int routePort, long networkGeneration)
      Resolve a physical attempt for a selected route authority.
      Parameters:
      routeHost - selected direct or alternative route host
      routePort - selected direct or alternative route port
      networkGeneration - network/discovery generation
      Returns:
      resolved target
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object