Interface ProxyConfigSelector
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@UnstableApi @FunctionalInterface public interface ProxyConfigSelector
Selects the
ProxyConfig to use when connecting to a network
resource specified by the SessionProtocol and Endpoint parameter.
This class may be used to dynamically control what proxy configuration
to use for each request.
It should be noted that the only guarantee provided is for a single request,
the Endpoint called with select(SessionProtocol, Endpoint) will be equal to
the Endpoint called with connectFailed(SessionProtocol, Endpoint,
SocketAddress, Throwable).
For instance, the actual SessionProtocol of the connection may differ from
the originally requested SessionProtocol depending on the result of protocol negotiation.
Similarly, the actual Endpoint of the request may differ from the originally requested
Endpoint.
-
Method Summary
Modifier and Type Method Description default voidconnectFailed(SessionProtocol protocol, Endpoint endpoint, SocketAddress sa, Throwable throwable)Called to indicate a connection attempt to the specifiedSessionProtocolandEndpointhas failed.static ProxyConfigSelectorof(ProxyConfig proxyConfig)Returns aProxyConfigSelectorwhich selects a staticProxyConfigfor all requests.static ProxyConfigSelectorof(ProxySelector proxySelector)Provides a way to reuse an existingProxySelectorwith some limitations.ProxyConfigselect(SessionProtocol protocol, Endpoint endpoint)Selects theProxyConfigto use when connecting to a network resource specified by theSessionProtocolandEndpointparameter.
-
Method Details
-
of
Provides a way to reuse an existingProxySelectorwith some limitations.- Incompatibilities when used with JDK's default
ProxySelectorimplementation:- Some properties like socksProxyVersion aren't respected
- This class doesn't attempt to resolve scheme format differences.
However, armeria uses some schemes such as "h1c", "h2" which aren't supported by JDK's
default
ProxySelector. This may be a source of unexpected behavior.
- Selecting multiple
Proxyisn't supported
- Incompatibilities when used with JDK's default
-
of
Returns aProxyConfigSelectorwhich selects a staticProxyConfigfor all requests. -
select
Selects theProxyConfigto use when connecting to a network resource specified by theSessionProtocolandEndpointparameter.- Parameters:
protocol- the protocol associated with the endpointendpoint- an endpoint containing the requested host and port- Returns:
- the selected proxy config which should be non-null
-
connectFailed
default void connectFailed(SessionProtocol protocol, Endpoint endpoint, SocketAddress sa, Throwable throwable)Called to indicate a connection attempt to the specifiedSessionProtocolandEndpointhas failed.- Parameters:
protocol- the protocol associated with the endpointendpoint- an endpoint containing the requested host and portsa- the remote socket address of the proxy serverthrowable- the cause of the failure
-