Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions source/common/http/conn_pool_grid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ void ConnectivityGrid::WrapperCallbacks::newStream() {
auto attempt = std::make_unique<ConnectionAttemptCallbacks>(*this, current_);
LinkedList::moveIntoList(std::move(attempt), connection_attempts_);
if (!next_attempt_timer_->enabled()) {
// TODO(#15649) When adding config for the grid, make this configurable.
next_attempt_timer_->enableTimer(std::chrono::milliseconds(300));
next_attempt_timer_->enableTimer(grid_.next_attempt_duration_);
}
}

Expand Down Expand Up @@ -117,10 +116,10 @@ ConnectivityGrid::ConnectivityGrid(
const Network::ConnectionSocket::OptionsSharedPtr& options,
const Network::TransportSocketOptionsSharedPtr& transport_socket_options,
Upstream::ClusterConnectivityState& state, TimeSource& time_source,
ConnectivityOptions connectivity_options)
std::chrono::milliseconds next_attempt_duration, ConnectivityOptions connectivity_options)
: dispatcher_(dispatcher), random_generator_(random_generator), host_(host),
priority_(priority), options_(options), transport_socket_options_(transport_socket_options),
state_(state), time_source_(time_source) {
state_(state), next_attempt_duration_(next_attempt_duration), time_source_(time_source) {
// TODO(#15649) support v6/v4, WiFi/cellular.
ASSERT(connectivity_options.protocols_.size() == 3);
ASSERT(contains(connectivity_options.protocols_,
Expand Down
2 changes: 2 additions & 0 deletions source/common/http/conn_pool_grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class ConnectivityGrid : public ConnectionPool::Instance,
const Network::ConnectionSocket::OptionsSharedPtr& options,
const Network::TransportSocketOptionsSharedPtr& transport_socket_options,
Upstream::ClusterConnectivityState& state, TimeSource& time_source,
std::chrono::milliseconds next_attempt_duration,
ConnectivityOptions connectivity_options);
~ConnectivityGrid() override;

Expand Down Expand Up @@ -130,6 +131,7 @@ class ConnectivityGrid : public ConnectionPool::Instance,
const Network::ConnectionSocket::OptionsSharedPtr& options_;
const Network::TransportSocketOptionsSharedPtr& transport_socket_options_;
Upstream::ClusterConnectivityState& state_;
std::chrono::milliseconds next_attempt_duration_;
TimeSource& time_source_;

// Tracks how many drains are needed before calling drain callbacks. This is
Expand Down
7 changes: 5 additions & 2 deletions test/common/http/conn_pool_grid_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ using Envoy::Event::MockTimer;
using testing::_;
using testing::AnyNumber;
using testing::Return;
using testing::StrictMock;

namespace Envoy {
namespace Http {
Expand Down Expand Up @@ -87,7 +88,7 @@ class ConnectivityGridTest : public Event::TestUsingSimulatedTime, public testin
grid_(dispatcher_, random_,
Upstream::makeTestHost(cluster_, "hostname", "tcp://127.0.0.1:9000", simTime()),
Upstream::ResourcePriority::Default, socket_options_, transport_socket_options_,
state_, simTime(), options_) {}
state_, simTime(), std::chrono::milliseconds(300), options_) {}

const Network::ConnectionSocket::OptionsSharedPtr socket_options_;
const Network::TransportSocketOptionsSharedPtr transport_socket_options_;
Expand Down Expand Up @@ -152,7 +153,9 @@ TEST_F(ConnectivityGridTest, TimeoutThenSuccessParallelSecondConnects) {
EXPECT_EQ(grid_.first(), nullptr);

// This timer will be returned and armed as the grid creates the wrapper's failover timer.
Event::MockTimer* failover_timer = new NiceMock<MockTimer>(&dispatcher_);
Event::MockTimer* failover_timer = new StrictMock<MockTimer>(&dispatcher_);
EXPECT_CALL(*failover_timer, enableTimer(std::chrono::milliseconds(300), nullptr)).Times(2);
EXPECT_CALL(*failover_timer, enabled()).WillRepeatedly(Return(false));

grid_.newStream(decoder_, callbacks_);
EXPECT_NE(grid_.first(), nullptr);
Expand Down