Skip to content
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

conn_pool: Minor cleanups to ConnPoolBaseImpl #17710

Merged
merged 5 commits into from
Aug 23, 2021

Conversation

RyanTheOptimist
Copy link
Contributor

@RyanTheOptimist RyanTheOptimist commented Aug 13, 2021

A few minor cleanups.

  • Add "Impl" suffix to methods in ConnPoolBaseImpl which shadow methods in ConnectionPool::Instance since ConnPoolBaseImpl does not actually implement this interfaces, but is extended by classes which do implement it and then need to disambiguate between the Base and Interface methods of the same name.
  • Convert a few structs to classes since they extend classes

Risk Level: Low - No behavior change
Testing: N/A - No behavior change
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Ryan Hamilton <rch@google.com>
…ch shadow methods in ConnectionPool::Instance

Signed-off-by: Ryan Hamilton <rch@google.com>
@RyanTheOptimist
Copy link
Contributor Author

/assign @DavidSchinazi

@RyanTheOptimist
Copy link
Contributor Author

@DavidSchinazi the diff shows a big chunk of changes in onConnectionEvent(), but that code is simply moving (and changing indentation) but is not actually modified. (It's moving from an "if (foo)" block to after an "if (!foo)" block returns.

Signed-off-by: Ryan Hamilton <rch@google.com>
DavidSchinazi
DavidSchinazi previously approved these changes Aug 16, 2021
@DavidSchinazi
Copy link
Contributor

/assign @alyssawilk

Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's chat about this when you're back - I like the naming changes but I think the early returns may not justify losing git history
/wait

@RyanTheOptimist
Copy link
Contributor Author

Let's chat about this when you're back - I like the naming changes but I think the early returns may not justify losing git history
/wait

I agree that it's annoying that refactors make git blame harder. In this case, I think there are a few things which argue in favor of the cleanup. The largest is that there are ~70 lines of code between the start of the if () and the end of the else if (). This means that if you're attempting to read this code, you have to page through (something like) 2-3 screenfuls of code to see if there is more logic after that block. It's also annoying that the code has one condition in the if () for the two close enum values (Local or Remote) and then another else if for Connected. But the code itself does not make clear if there are other values of the enum which are intentionally not handled. As it turns out, there are only 3. So this means that the if else could be replaced by simply an else. I'd argue that replacing it with an else (and a DCHECK that the value is Connected) would be a net with for readability. But once we've done that (and I did this initially :>) we end up with a 5-line bit of code after like 60 lines of code in the Close case. So moving this to the top and returning early seems like the logical thing to do in order to make the code easier to read.

@antoniovicente Can you be a tie-breaker here :)

@RyanTheOptimist
Copy link
Contributor Author

/assign @antoniovicente

@antoniovicente
Copy link
Contributor

Let's chat about this when you're back - I like the naming changes but I think the early returns may not justify losing git history
/wait

I agree that it's annoying that refactors make git blame harder. In this case, I think there are a few things which argue in favor of the cleanup. The largest is that there are ~70 lines of code between the start of the if () and the end of the else if (). This means that if you're attempting to read this code, you have to page through (something like) 2-3 screenfuls of code to see if there is more logic after that block. It's also annoying that the code has one condition in the if () for the two close enum values (Local or Remote) and then another else if for Connected. But the code itself does not make clear if there are other values of the enum which are intentionally not handled. As it turns out, there are only 3. So this means that the if else could be replaced by simply an else. I'd argue that replacing it with an else (and a DCHECK that the value is Connected) would be a net with for readability. But once we've done that (and I did this initially :>) we end up with a 5-line bit of code after like 60 lines of code in the Close case. So moving this to the top and returning early seems like the logical thing to do in order to make the code easier to read.

@antoniovicente Can you be a tie-breaker here :)

Interesting tiebreak choice since I have been known to be someone that attempts to preserve git history at all costs despite consequences and keeps asking people to revert whitespace changes. Also, I don't mind excessive nesting of code; I consider nesting preferable to non-trivial early returns like the one you added at https://github.com/envoyproxy/envoy/pull/17710/files#diff-1ca21bd145a8c09791b9659ca8cdfbec5dfb86067b8f4615981ae618ac31cc7fR419. :)

Signed-off-by: Ryan Hamilton <rch@google.com>
@RyanTheOptimist
Copy link
Contributor Author

Interesting tiebreak choice since I have been known to be someone that attempts to preserve git history at all costs despite consequences and keeps asking people to revert whitespace changes. Also, I don't mind excessive nesting of code; I consider nesting preferable to non-trivial early returns like the one you added at https://github.com/envoyproxy/envoy/pull/17710/files#diff-1ca21bd145a8c09791b9659ca8cdfbec5dfb86067b8f4615981ae618ac31cc7fR419. :)

Heh, I chose you because I respect your judgement, not because I expected you to agree with me :) In any case, thanks for breaking the tie! I've reverted the early return change. PTAL

Copy link
Contributor

@antoniovicente antoniovicente left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup.

Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@alyssawilk alyssawilk merged commit d4960cc into envoyproxy:main Aug 23, 2021
mpuncel added a commit to mpuncel/envoy that referenced this pull request Aug 25, 2021
* main: (32 commits)
  Stop processing pending H/2 frames if connection transitioned to the closed state
  http2: limit use of deferred resets in the http2 codec to server-side connections
  Abort filter chain iteration on local reply
  Reject or strip fragment from request URI
  ext-authz: merge duplicate headers from client request in check request
  common: introduce stable logger /w examples in DNS  (envoyproxy#17772)
  route: fast return when route matches failed (envoyproxy#17769)
  owners: add owners for dubbo proxy network filter (envoyproxy#17820)
  config/router/tcp_proxy/options: v2 API, boosting and --bootstrap-version CLI removal. (envoyproxy#17724)
  coverage: revert the limit http/cache to 92.6. (envoyproxy#17817)
  network: rename SocketAddressProvider as ConnectionInfoProvider (envoyproxy#17717)
  test: bumping coverage (envoyproxy#17757)
  conn_pool: Minor cleanups to ConnPoolBaseImpl (envoyproxy#17710)
  Split VaryHeader into VaryAllowList and VaryUtils to organize vary-related logic (envoyproxy#17728)
  ext_proc: Make tests more resilient to IPv6 support (envoyproxy#17784)
  Remove invlaid backquote from doc (envoyproxy#17797)
  rocketmq: move to contrib (envoyproxy#17796)
  kafka: upstream kafka facade in mesh-filter (envoyproxy#17783)
  ecds: create shared base class for DynamicFilterConfigProviderImpl (envoyproxy#17735)
  Change log level from debug to trace (envoyproxy#17774)
  ...

Signed-off-by: Michael Puncel <mpuncel@squareup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants