upstream_ready_cb_(dispatcher_.createSchedulableCallback([this]() { onUpstreamReady(); })),
for (auto* list : {&ready_clients_, &busy_clients_, &connecting_clients_, &early_data_clients_}) {
ENVOY_LOG(debug, "creating a new connection (connecting={})", connecting_clients_.size());
if (enforceMaxRequests() && !host_->cluster().resourceManager(priority_).requests().canCreate()) {
debug, "destroying stream: {} active remaining, readyForStream {}, currentUnusedCapacity {}",
client, client.numActiveStreams(), client.readyForStream(), client.currentUnusedCapacity());
client.remaining_streams_ > client.concurrent_stream_limit_ - client.numActiveStreams() - 1;
} else if (client.state() == ActiveClient::State::Busy && client.currentUnusedCapacity() > 0) {
// Even if there's a ready client, we may want to preconnect to handle the next incoming stream.
return tryCreateNewConnection(global_preconnect_ratio) == ConnectionResult::CreatedNewConnection;
void ConnPoolImplBase::addIdleCallbackImpl(Instance::IdleCb cb) { idle_callbacks_.push_back(cb); }
// closeIdleConnectionsForDrainingPool() closes all connections in ready_clients_ with no active
// streams as well, so all remaining entries in ready_clients_ are serving streams. Move them and
void ConnPoolImplBase::onConnectionEvent(ActiveClient& client, absl::string_view failure_reason,
// streams and active streams, and makes sure the connecting capacity would still be sufficient to
// Note that this is a O(n) search, but the expected size of pending_streams_ should be small. If
parent_.transitionActiveClientState(*this, Envoy::ConnectionPool::ActiveClient::State::Draining);
// it sees the connection as currently limited by concurrent capacity, not total lifetime streams.
// connection as limited for that reason, because it is now being marked as having zero remaining