#pragma once #include "common/upstream/conn_pool_map_impl.h" #include "common/upstream/priority_conn_pool_map.h" namespace Envoy { namespace Upstream { template PriorityConnPoolMap::PriorityConnPoolMap(Envoy::Event::Dispatcher& dispatcher, const HostConstSharedPtr& host) { for (size_t pool_map_index = 0; pool_map_index < NumResourcePriorities; ++pool_map_index) { auto priority = static_cast(pool_map_index); conn_pool_maps_[pool_map_index].reset(new ConnPoolMapType(dispatcher, host, priority)); } } template PriorityConnPoolMap::~PriorityConnPoolMap() = default; template typename PriorityConnPoolMap::PoolOptRef PriorityConnPoolMap::getPool(ResourcePriority priority, KEY_TYPE key, const PoolFactory& factory) { size_t index = static_cast(priority); ASSERT(index < conn_pool_maps_.size()); return conn_pool_maps_[index]->getPool(key, factory); } template size_t PriorityConnPoolMap::size() const { size_t size = 0; for (const auto& pool_map : conn_pool_maps_) { size += pool_map->size(); } return size; } template void PriorityConnPoolMap::clear() { for (auto& pool_map : conn_pool_maps_) { pool_map->clear(); } } template void PriorityConnPoolMap::addDrainedCallback(const DrainedCb& cb) { for (auto& pool_map : conn_pool_maps_) { pool_map->addDrainedCallback(cb); } } template void PriorityConnPoolMap::drainConnections() { for (auto& pool_map : conn_pool_maps_) { pool_map->drainConnections(); } } } // namespace Upstream } // namespace Envoy