Skip to content

conn_pool: cleaning up interfaces#11796

Merged
alyssawilk merged 5 commits intoenvoyproxy:masterfrom
alyssawilk:void2
Jul 1, 2020
Merged

conn_pool: cleaning up interfaces#11796
alyssawilk merged 5 commits intoenvoyproxy:masterfrom
alyssawilk:void2

Conversation

@alyssawilk
Copy link
Copy Markdown
Contributor

Removing two "friend class" declarations by providing necessary accessors.
Replacing void* context with castable context.

Risk Level: Low (no-op refactor)
Testing: n/a
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Copy Markdown
Contributor Author

WDYT? Better than voids?

@ggreenway
Copy link
Copy Markdown
Member

For the AttachContext, I think it would make it better if you have the actual context inherit from AttachContext, change all the reinterpret_cast to static_cast, and optionally ASSERT(dynamic_cast<type>(context) != nullptr).

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks LGTM with small comment.

/wait

Comment on lines +69 to +71
Http::ResponseDecoder& decoder = *static_cast<const HttpAttachContext*>(&context)->decoder_;
Http::ConnectionPool::Callbacks& callbacks =
*static_cast<const HttpAttachContext*>(&context)->callbacks_;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Technically I think you should do dynamic_cast here and elsewhere. You might consider a helper that does it and returns the real object, or just a template method on the interface like we for for thread local storage slots.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Heh, Greg had me go from reinterpret to static. I think static cast is consistent with the style guide*. Maybe I could add ASSERTS for dynamic cast like Greg suggested?

*https://google.github.io/styleguide/cppguide.html#Casting

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sure dynamic_cast in ASSERT SGTM, I would still put it in a templated helper though on the interface. Can you potentially take an action to change the ThreadLocal interface to do the same thing? There might be a nice perf boost there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

template function added. lmk if it's not what you were looking for.
Sadly when I tried to add the dynamic cast assert it failed because not polymorphic - no virtuals in the base class). I could add some or we could leave as-is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also yeah, happy to do the follow-up with TLS.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes this LGTM, sorry why does the dynamic_cast fail? The virtual destructor doesn't count?

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
mattklein123
mattklein123 previously approved these changes Jun 29, 2020

// A placeholder struct for whatever data a given connection pool needs to
// successfully attach and upstream connection to a downstream connection.
struct AttachContext {};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh I see, here. Yeah just add a virtual destructor and the dynamic_cast will work? This is what we do for the ThreadLocal code. Up to you.

Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

Yeah, let's add a virtual destructor, then add the dynamic_cast assert.

/wait

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk alyssawilk merged commit 011945d into envoyproxy:master Jul 1, 2020
alyssawilk added a commit that referenced this pull request Jul 7, 2020
requested follow-up PR from #11796 as it's more consistent with our style guide.

Risk Level: low
Testing: n/a
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
scheler pushed a commit to scheler/envoy that referenced this pull request Aug 4, 2020
requested follow-up PR from envoyproxy#11796 as it's more consistent with our style guide.

Risk Level: low
Testing: n/a
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: scheler <santosh.cheler@appdynamics.com>
@alyssawilk alyssawilk deleted the void2 branch October 26, 2020 21:16
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.

3 participants