-
Notifications
You must be signed in to change notification settings - Fork 5.5k
conn_pool: Remove startDrain() and replace it with an argument to drainConnections #17960
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
Changes from 5 commits
8844951
f618ce6
f580f4e
485688c
2f2a280
179cdd4
8d5f90e
ea6bf0f
4307372
606f3cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,21 @@ class Cancellable { | |
| virtual void cancel(CancelPolicy cancel_policy) PURE; | ||
| }; | ||
|
|
||
| /** | ||
| * Controls the behavior when draining a connection pool. | ||
| */ | ||
| enum class DrainBehavior { | ||
| // Starts draining a pool, by gracefully completing all requests and gracefully closing all | ||
| // connections, in preparation for deletion. | ||
| // can be immediately drained. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make this a proper sentence
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh whoop. That should just be removed. Done. |
||
| DrainAndDelete, | ||
| // Actively drain all existing connection pool connections. This can be used in cases where | ||
| // the connection pool is not being destroyed, but the caller wishes to make sure that | ||
| // all new streams take place on a new connection. For example, when a health check failure | ||
| // occurs. | ||
| DrainExistingConnections, | ||
| }; | ||
|
|
||
| /** | ||
| * An instance of a generic connection pool. | ||
| */ | ||
|
|
@@ -59,20 +74,10 @@ class Instance { | |
| virtual bool isIdle() const PURE; | ||
|
|
||
| /** | ||
| * Starts draining a pool, by gracefully completing all requests and gracefully closing all | ||
| * connections, in preparation for deletion. When the process completes, the function registered | ||
| * via `addIdleCallback()` is called. The callback may occur before this call returns if the pool | ||
| * can be immediately drained. | ||
| */ | ||
| virtual void startDrain() PURE; | ||
|
|
||
| /** | ||
| * Actively drain all existing connection pool connections. This method can be used in cases | ||
| * where the connection pool is not being destroyed, but the caller wishes to make sure that | ||
| * all new streams take place on a new connection. For example, when a health check failure | ||
| * occurs. | ||
| * Drains the connections in a pool. | ||
| * @param drain_behavior A DrainBehavior that controls the behavior of the draining. | ||
| */ | ||
| virtual void drainConnections() PURE; | ||
| virtual void drainConnections(DrainBehavior drain_behavior) PURE; | ||
|
|
||
| /** | ||
| * @return Upstream::HostDescriptionConstSharedPtr the host for which connections are pooled. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -331,11 +331,6 @@ void ConnPoolImplBase::transitionActiveClientState(ActiveClient& client, | |
|
|
||
| void ConnPoolImplBase::addIdleCallbackImpl(Instance::IdleCb cb) { idle_callbacks_.push_back(cb); } | ||
|
|
||
| void ConnPoolImplBase::startDrainImpl() { | ||
| is_draining_ = true; | ||
| checkForIdleAndCloseIdleConnsIfDraining(); | ||
| } | ||
|
|
||
| void ConnPoolImplBase::closeIdleConnectionsForDrainingPool() { | ||
| // Create a separate list of elements to close to avoid mutate-while-iterating problems. | ||
| std::list<ActiveClient*> to_close; | ||
|
|
@@ -359,7 +354,12 @@ void ConnPoolImplBase::closeIdleConnectionsForDrainingPool() { | |
| } | ||
| } | ||
|
|
||
| void ConnPoolImplBase::drainConnectionsImpl() { | ||
| void ConnPoolImplBase::drainConnectionsImpl(DrainBehavior drain_behavior) { | ||
| if (drain_behavior == Envoy::ConnectionPool::DrainBehavior::DrainAndDelete) { | ||
| checkForIdleAndCloseIdleConnsIfDraining(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function behaves differently depending on the value of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh shoot! Thanks. I think I screwed that up during a cleanup. Fixed. |
||
| is_draining_ = true; | ||
| return; | ||
| } | ||
| closeIdleConnectionsForDrainingPool(); | ||
|
|
||
| // closeIdleConnections() closes all connections in ready_clients_ with no active streams, | ||
|
|
||
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.
Please add that it is invalid to create new requests/streams/connections on this pool after this call.
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.
Good idea. Done.