-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
hyper-util: expose connection info on whether it's reused from the pool or newly established #3727
Comments
Since the |
That makes total sense. What we are specifically interested in is to expose the "reused or not" information only on error cases, so I thought that we could add Given these things, now I think the interface as follows would be good: pub struct Error {
kind: ErrorKind,
source: Option<Box<dyn StdError + Send + Sync>>,
#[cfg(any(feature = "http1", feature = "http2"))]
- connect_info: Option<Connected>,
+ connect_info: Option<ConnectInfo>,
}
+ /// Instead of adding `is_reused` to `Connected`, we define a new struct here
+ /// to hold a raw `Connected`, which has protocol-related information, and
+ /// `is_reused` flag, which is connection pool related information.
+ pub struct ConnectInfo {
+ connected: Connected,
+ is_reused: bool,
+ }
+
+ /// Instead of exposing all the methods of `Connected`, we expose getter methods
+ /// that allow callers to get necessary information about the failed connection.
+ impl ConnectInfo {
+ pub fn is_proxied(&self) -> bool {
+ self.connected.is_proxied()
+ }
+
+ pub fn get_extras(&self, extensions: &mut Extensions) {
+ self.connected.get_extras(extensions);
+ }
+
+ pub fn is_negotiated_h2(&self) -> bool {
+ self.connected.is_negotiated_h2()
+ }
+
+ pub fn is_reused(&self) -> bool {
+ self.is_reused
+ }
+} What do you think about this approach? The concern I have with this is that this will be a breaking change as the return type of Error::connect_info will be changed. Not sure if this is acceptable or not though. |
I implemented based on my proposed approach in hyperium/hyper-util#145. Any thoughts or feedback would be appreciated. |
Is your feature request related to a problem? Please describe.
While investigating hard-to-debug connection related issues in cloud infra, we will likely want to obtain any kind of information that might be relevant. Even whether a connection that has just failed is reused from the connection pool or is newly established can be a valuable insight that we could use to troubleshoot.
Describe the solution you'd like
Maybe add a new private field to the
hyper_util::client::legacy::connect::HttpInfo
, likeis_new_connection
(oris_reused_connection
) and make it publicly accessible via a method?Describe alternatives you've considered
I didn't come up with other alternatives
Additional context
N/A
The text was updated successfully, but these errors were encountered: