-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let ConnectionFactory
see difference between proxied and direct connections
#2169
Let ConnectionFactory
see difference between proxied and direct connections
#2169
Conversation
ConnectionFactory
see difference between proxied and direct connectionsConnectionFactory
to see difference between proxied and direct connections
ConnectionFactory
to see difference between proxied and direct connectionsConnectionFactory
see difference between proxied and direct connections
servicetalk-client-api/src/main/java/io/servicetalk/client/api/ConnectionFactory.java
Outdated
Show resolved
Hide resolved
servicetalk-client-api/src/main/java/io/servicetalk/client/api/LoadBalancer.java
Outdated
Show resolved
Hide resolved
Single<C> newConnection(ResolvedAddress address, @Nullable TransportObserver observer); | ||
default Single<C> newConnection(ResolvedAddress address, @Nullable ContextMap context, | ||
@Nullable TransportObserver observer) { // FIXME: 0.43 - remove default impl | ||
return Single.defer(() -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will the implementation be when Connection factory implementations override this method? Are they to implement the defer and the addition of the key to the context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the defer
here is only necessary to "glue" the old overload with DeprecatedToNewConnectionFactoryFilter
. If users implement this method, it's expected that they will invoke the same method in delegate chain, skipping the AsyncContext dance and directly propagating the context
to the next filter.
/** | ||
* Default implementation of {@link ContextMap}. | ||
* <p> | ||
* Note: it's not concurrent! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose better wording would be "it's not thread-safe".
Motivation: Connection initialization sequence is different for a secure HTTP proxy tunnels. It's necessary for the `ConnectionFactory` and `TransportObserver` to know if the `newConnection` is invoked for a regular connection or a proxy tunnel in order to correctly count timing of events. Modifications: - Introduce new `HttpContextKeys#HTTP_TARGET_ADDRESS_BEHIND_PROXY` key; - Enhance `ProxyConnectConnectionFactoryFilter` and `AbsoluteAddressHttpRequesterFilter` to fill the value for `HTTP_TARGET_ADDRESS_BEHIND_PROXY`; - Enhance proxy tests to verify that the key value always present; Result: Users can distinguish attempts to open direct connections and connections through a proxy.
7104d9a
to
cae941b
Compare
Motivation: Prior to `ConnectionObserver.ProxyConnectObserver` added in apple#2711, the sequence of `ConnectionObserver` events was different between regular connections and connection to the proxy tunnels. `HttpContextKeys.HTTP_TARGET_ADDRESS_BEHIND_PROXY` (apple#2169) was useful to distinguish when the correct callback inside `ConnectionObserver` before reporting that a new connection is ready to take traffic. After adding `ProxyConnectObserver`, there is no need in this custom key. Modifications: - Deprecate `HttpContextKeys.HTTP_TARGET_ADDRESS_BEHIND_PROXY` and describe what is an appropriate replacement for users; Result: We will be able to remove `HttpContextKeys.HTTP_TARGET_ADDRESS_BEHIND_PROXY` in the future releases.
Motivation: Prior to `ConnectionObserver.ProxyConnectObserver` added in #2711, the sequence of `ConnectionObserver` events was different between regular connections and connection to the proxy tunnels. `HttpContextKeys.HTTP_TARGET_ADDRESS_BEHIND_PROXY` (#2169) was useful to distinguish when the correct callback inside `ConnectionObserver` before reporting that a new connection is ready to take traffic. After adding `ProxyConnectObserver`, there is no need in this custom key. Modifications: - Deprecate `HttpContextKeys.HTTP_TARGET_ADDRESS_BEHIND_PROXY` and describe what is an appropriate replacement for users; Result: We will be able to remove `HttpContextKeys.HTTP_TARGET_ADDRESS_BEHIND_PROXY` in the future releases.
Motivation:
The connection initialization sequence is different for secure HTTP proxy
tunnels. It's necessary for the
ConnectionFactory
andTransportObserver
to know if thenewConnection(...)
is being invoked fora regular connection or a proxy tunnel in order to correctly count timing
of events.
Modifications:
HttpContextKeys#HTTP_TARGET_ADDRESS_BEHIND_PROXY
key;ProxyConnectConnectionFactoryFilter
andAbsoluteAddressHttpRequesterFilter
to fill in the value forHTTP_TARGET_ADDRESS_BEHIND_PROXY
;Result:
Users can distinguish attempts to open direct connections and
connections through a proxy.
Depends on #2168, review starting from the 2nd commit.