http: refactoring http and tcp upstreams#11349
Conversation
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
|
cc @lambdai |
|
|
||
| // Initializes the connection pool. This must be called before the connection | ||
| // pool is valid, and can be used. | ||
| virtual bool initialize(Upstream::ClusterManager& cm, const RouteEntry& route_entry, |
There was a problem hiding this comment.
I am wondering if we can avoid passing the protocol here. But the alternatives are highly coupled with cluster :)
There was a problem hiding this comment.
Based on the config proposal that @alyssawilk and I discussed today, I think that ultimately we are going to have to pass the cluster here, as that is where all of the selection logic is going to be stored that will determine which concrete impl to initialize?
I think my larger question is can we avoid an initialize() function entirely? It seems like what we actually will end up needing is a factory which produces a conn pool? I think that is what is going to be needed for the final impl that is pluggable? Alyssa do you want to tackle that now or later? (Personally I think it might be worth it to develop the factory in this PR and use it, even if there is no config that drives it.)
There was a problem hiding this comment.
I don't think we can avoid an initialize function or some sort of validity check.
Agree we'll need a factory. My thought was to merge this, and then do the factory and config over in #11327
I think basically that PR will get the config from the cluster, then use that to generate a get a third type of pool, the envoy.default one which creates TCP or HTTP based on "is this a connect request"
There was a problem hiding this comment.
actually I take that back - we can avoid the initialize function if we allow the factory creation function to return nullptr, if we prefer that mode
There was a problem hiding this comment.
Yeah this is what I had assumed we would do. Do you want to do that in this PR or in a follow up?
| HttpOrTcpPool createConnPool(Upstream::HostDescriptionConstSharedPtr& host); | ||
| UpstreamRequestPtr createUpstreamRequest(Filter::HttpOrTcpPool conn_pool); | ||
| std::unique_ptr<GenericConnPool> createConnPool(); | ||
| UpstreamRequestPtr createUpstreamRequest(std::unique_ptr<GenericConnPool>&& conn_pool); |
There was a problem hiding this comment.
Mark: I don't see the definition in PR... github issue?
There was a problem hiding this comment.
I didn't find the impl anywhere but envoy is built successfully... Please educate me
My initial intention is to argue if we need the rvalue reference "&&" in parameter
| private: | ||
| // Points to the actual connection pool to create streams from. | ||
| Http::ConnectionPool::Instance& conn_pool_; | ||
| Http::ConnectionPool::Instance* conn_pool_; |
There was a problem hiding this comment.
nit: now that it's no longer reference we can assign the default value '{}'
| class TcpConnPool : public GenericConnPool, public Tcp::ConnectionPool::Callbacks { | ||
| public: | ||
| TcpConnPool(Tcp::ConnectionPool::Instance* conn_pool) : conn_pool_(conn_pool) {} | ||
| TcpConnPool() = default; |
| class HttpConnPool : public GenericConnPool, public Http::ConnectionPool::Callbacks { | ||
| public: | ||
| HttpConnPool(Http::ConnectionPool::Instance& conn_pool) : conn_pool_(conn_pool) {} | ||
| HttpConnPool() = default; |
mattklein123
left a comment
There was a problem hiding this comment.
LGTM modulo @lambdai comments and one larger question about structure. Thank you!
/wait
|
|
||
| // Initializes the connection pool. This must be called before the connection | ||
| // pool is valid, and can be used. | ||
| virtual bool initialize(Upstream::ClusterManager& cm, const RouteEntry& route_entry, |
There was a problem hiding this comment.
Based on the config proposal that @alyssawilk and I discussed today, I think that ultimately we are going to have to pass the cluster here, as that is where all of the selection logic is going to be stored that will determine which concrete impl to initialize?
I think my larger question is can we avoid an initialize() function entirely? It seems like what we actually will end up needing is a factory which produces a conn pool? I think that is what is going to be needed for the final impl that is pluggable? Alyssa do you want to tackle that now or later? (Personally I think it might be worth it to develop the factory in this PR and use it, even if there is no config that drives it.)
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
|
follow up if you're OK with the churn - I've got the next in line mostly ready to go and would prefer to start the config discussion earlier than later. |
mattklein123
left a comment
There was a problem hiding this comment.
OK sounds good to do a follow up.
Moving the choice of http or tcp connection pool from the router to the generic connection pool. This will allow pluggable connection pools to choose to do HTTP or TCP on their own, as well as getting rid of a bunch of ugly variant logic. Risk Level: medium (router refactor, ideally no-op) Testing: existing test pass Docs Changes: n/a Release Notes: n/a Signed-off-by: Alyssa Wilk <alyssar@chromium.org> Signed-off-by: Auni Ahsan <auni@google.com>
Moving the choice of http or tcp connection pool from the router to the generic connection pool. This will allow pluggable connection pools to choose to do HTTP or TCP on their own, as well as getting rid of a bunch of ugly variant logic. Risk Level: medium (router refactor, ideally no-op) Testing: existing test pass Docs Changes: n/a Release Notes: n/a Signed-off-by: Alyssa Wilk <alyssar@chromium.org> Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
Moving the choice of http or tcp connection pool from the router to the generic connection pool.
This will allow pluggable connection pools to choose to do HTTP or TCP on their own, as well as getting rid of a bunch of ugly variant logic.
Risk Level: medium (router refactor, ideally no-op)
Testing: existing test pass
Docs Changes: n/a
Release Notes: n/a