Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Flacco <nflacco@lyft.com>
  • Loading branch information
1 parent e6731a9 commit 35b6128
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 23 deletions.
7 changes: 4 additions & 3 deletions source/extensions/clusters/redis/redis_cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ RedisCluster::RedisCluster(
: Config::Utility::translateClusterHosts(cluster.hosts())),
local_info_(factory_context.localInfo()), random_(factory_context.random()),
redis_discovery_session_(*this, redis_client_factory), lb_factory_(std::move(lb_factory)),
api_(api),
redis_cluster_stats_{REDIS_CLUSTER_STATS(POOL_COUNTER(info()->statsScope()), POOL_HISTOGRAM(info()->statsScope()))} {
api_(api), redis_cluster_stats_{REDIS_CLUSTER_STATS(POOL_COUNTER(info()->statsScope()),
POOL_HISTOGRAM(info()->statsScope()))} {
const auto& locality_lb_endpoints = load_assignment_.endpoints();
for (const auto& locality_lb_endpoint : locality_lb_endpoints) {
for (const auto& lb_endpoint : locality_lb_endpoint.lb_endpoints()) {
Expand Down Expand Up @@ -241,7 +241,8 @@ void RedisCluster::RedisDiscoverySession::startResolveRedis() {
if (!client) {
client = std::make_unique<RedisDiscoveryClient>(*this);
client->host_ = current_host_address_;
client->client_ = client_factory_.create(host, dispatcher_, *this, parent_.redis_cluster_stats_);
client->client_ =
client_factory_.create(host, dispatcher_, *this, parent_.redis_cluster_stats_);
client->client_->addConnectionCallbacks(*client);
std::string auth_password =
Envoy::Config::DataSource::read(parent_.auth_password_datasource_, true, parent_.api_);
Expand Down
17 changes: 10 additions & 7 deletions source/extensions/filters/network/common/redis/client_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ ClientPtr ClientImpl::create(Upstream::HostConstSharedPtr host, Event::Dispatche
EncoderPtr&& encoder, DecoderFactory& decoder_factory,
const Config& config, RedisClusterStats& redis_cluster_stats) {

std::unique_ptr<ClientImpl> client(
new ClientImpl(host, dispatcher, std::move(encoder), decoder_factory, config, redis_cluster_stats));
std::unique_ptr<ClientImpl> client(new ClientImpl(host, dispatcher, std::move(encoder),
decoder_factory, config, redis_cluster_stats));
client->connection_ = host->createConnection(dispatcher, nullptr, nullptr).connection_;
client->connection_->addConnectionCallbacks(*client);
client->connection_->addReadFilter(Network::ReadFilterSharedPtr{new UpstreamReadFilter(*client)});
Expand All @@ -36,13 +36,13 @@ ClientPtr ClientImpl::create(Upstream::HostConstSharedPtr host, Event::Dispatche
}

ClientImpl::ClientImpl(Upstream::HostConstSharedPtr host, Event::Dispatcher& dispatcher,
EncoderPtr&& encoder, DecoderFactory& decoder_factory, const Config& config, RedisClusterStats& redis_cluster_stats)
EncoderPtr&& encoder, DecoderFactory& decoder_factory, const Config& config,
RedisClusterStats& redis_cluster_stats)
: host_(host), encoder_(std::move(encoder)), decoder_(decoder_factory.create(*this)),
config_(config),
connect_or_op_timer_(dispatcher.createTimer([this]() -> void { onConnectOrOpTimeout(); })),
flush_timer_(dispatcher.createTimer([this]() -> void { flushBufferAndResetTimer(); })),
redis_cluster_stats_(redis_cluster_stats),
time_source_(dispatcher.timeSource()) {
redis_cluster_stats_(redis_cluster_stats), time_source_(dispatcher.timeSource()) {
host->cluster().stats().upstream_cx_total_.inc();
host->stats().cx_total_.inc();
host->cluster().stats().upstream_cx_active_.inc();
Expand Down Expand Up @@ -204,7 +204,9 @@ void ClientImpl::onRespValue(RespValuePtr&& value) {
}

ClientImpl::PendingRequest::PendingRequest(ClientImpl& parent, PoolCallbacks& callbacks)
: parent_(parent), callbacks_(callbacks), request_timer_(std::make_unique<Stats::Timespan>(parent_.redis_cluster_stats_.upstream_rq_time_, parent_.time_source_)) {
: parent_(parent), callbacks_(callbacks),
request_timer_(std::make_unique<Stats::Timespan>(
parent_.redis_cluster_stats_.upstream_rq_time_, parent_.time_source_)) {
parent.host_->cluster().stats().upstream_rq_total_.inc();
parent.host_->stats().rq_total_.inc();
parent.host_->cluster().stats().upstream_rq_active_.inc();
Expand All @@ -226,7 +228,8 @@ void ClientImpl::PendingRequest::cancel() {
ClientFactoryImpl ClientFactoryImpl::instance_;

ClientPtr ClientFactoryImpl::create(Upstream::HostConstSharedPtr host,
Event::Dispatcher& dispatcher, const Config& config, RedisClusterStats& redis_cluster_stats) {
Event::Dispatcher& dispatcher, const Config& config,
RedisClusterStats& redis_cluster_stats) {
return ClientImpl::create(host, dispatcher, EncoderPtr{new EncoderImpl()}, decoder_factory_,
config, redis_cluster_stats);
}
Expand Down
3 changes: 2 additions & 1 deletion source/extensions/filters/network/common/redis/client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ class ClientImpl : public Client, public DecoderCallbacks, public Network::Conne
};

ClientImpl(Upstream::HostConstSharedPtr host, Event::Dispatcher& dispatcher, EncoderPtr&& encoder,
DecoderFactory& decoder_factory, const Config& config, RedisClusterStats& redis_cluster_stats);
DecoderFactory& decoder_factory, const Config& config,
RedisClusterStats& redis_cluster_stats);
void onConnectOrOpTimeout();
void onData(Buffer::Instance& data);
void putOutlierEvent(Upstream::Outlier::Result result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ InstanceImpl::InstanceImpl(
Api::Api& api, Stats::ScopePtr&& stats_scope)
: cm_(cm), client_factory_(client_factory), tls_(tls.allocateSlot()), config_(config),
api_(api), stats_scope_(std::move(stats_scope)), redis_cluster_stats_{REDIS_CLUSTER_STATS(
POOL_COUNTER(*stats_scope_), POOL_HISTOGRAM(*stats_scope_))} {
POOL_COUNTER(*stats_scope_),
POOL_HISTOGRAM(*stats_scope_))} {
tls_->set([this, cluster_name](
Event::Dispatcher& dispatcher) -> ThreadLocal::ThreadLocalObjectSharedPtr {
return std::make_shared<ThreadLocalPool>(*this, dispatcher, cluster_name);
Expand Down Expand Up @@ -196,7 +197,8 @@ InstanceImpl::ThreadLocalPool::threadLocalActiveClient(Upstream::HostConstShared
if (!client) {
client = std::make_unique<ThreadLocalActiveClient>(*this);
client->host_ = host;
client->redis_client_ = parent_.client_factory_.create(host, dispatcher_, parent_.config_, parent_.redis_cluster_stats_);
client->redis_client_ = parent_.client_factory_.create(host, dispatcher_, parent_.config_,
parent_.redis_cluster_stats_);
client->redis_client_->addConnectionCallbacks(*client);
if (!auth_password_.empty()) {
// Send an AUTH command to the upstream server.
Expand Down
11 changes: 7 additions & 4 deletions source/extensions/health_checkers/redis/redis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ RedisHealthChecker::RedisHealthChecker(
Upstream::HealthCheckEventLoggerPtr&& event_logger,
Extensions::NetworkFilters::Common::Redis::Client::ClientFactory& client_factory)
: HealthCheckerImplBase(cluster, config, dispatcher, runtime, random, std::move(event_logger)),
client_factory_(client_factory), key_(redis_config.key()),
redis_cluster_stats_{REDIS_CLUSTER_STATS(POOL_COUNTER(cluster.info()->statsScope()), POOL_HISTOGRAM(cluster.info()->statsScope()))} {
if (!key_.empty()) {
client_factory_(client_factory),
key_(redis_config.key()), redis_cluster_stats_{REDIS_CLUSTER_STATS(
POOL_COUNTER(cluster.info()->statsScope()),
POOL_HISTOGRAM(cluster.info()->statsScope()))} {
if (!key_.empty()) {
type_ = Type::Exists;
} else {
type_ = Type::Ping;
Expand Down Expand Up @@ -52,7 +54,8 @@ void RedisHealthChecker::RedisActiveHealthCheckSession::onEvent(Network::Connect

void RedisHealthChecker::RedisActiveHealthCheckSession::onInterval() {
if (!client_) {
client_ = parent_.client_factory_.create(host_, parent_.dispatcher_, *this, parent_.redis_cluster_stats_);
client_ = parent_.client_factory_.create(host_, parent_.dispatcher_, *this,
parent_.redis_cluster_stats_);
client_->addConnectionCallbacks(*this);
}

Expand Down
3 changes: 2 additions & 1 deletion test/extensions/clusters/redis/redis_cluster_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class RedisClusterTest : public testing::Test,
// ClientFactory
Extensions::NetworkFilters::Common::Redis::Client::ClientPtr
create(Upstream::HostConstSharedPtr host, Event::Dispatcher&,
const Extensions::NetworkFilters::Common::Redis::Client::Config&, Extensions::NetworkFilters::Common::Redis::Client::RedisClusterStats&) override {
const Extensions::NetworkFilters::Common::Redis::Client::Config&,
Extensions::NetworkFilters::Common::Redis::Client::RedisClusterStats&) override {
EXPECT_EQ(22120, host->address()->ip()->port());
return Extensions::NetworkFilters::Common::Redis::Client::ClientPtr{
create_(host->address()->asString())};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class RedisClientImplTest : public testing::Test, public Common::Redis::DecoderF
return Common::Redis::DecoderPtr{decoder_};
}

RedisClientImplTest() : redis_cluster_stats_(RedisClusterStats{REDIS_CLUSTER_STATS(POOL_COUNTER(fake_stats_), POOL_HISTOGRAM(fake_stats_))}) {}
RedisClientImplTest()
: redis_cluster_stats_(RedisClusterStats{
REDIS_CLUSTER_STATS(POOL_COUNTER(fake_stats_), POOL_HISTOGRAM(fake_stats_))}) {}

~RedisClientImplTest() override {
client_.reset();
Expand Down Expand Up @@ -282,7 +284,6 @@ TEST_F(RedisClientImplTest, Basic) {
EXPECT_EQ(2UL, host_->cluster_.stats_.upstream_rq_active_.value());
EXPECT_EQ(2UL, host_->stats_.rq_total_.value());
EXPECT_EQ(2UL, host_->stats_.rq_active_.value());


Buffer::OwnedImpl fake_data;
EXPECT_CALL(*decoder_, decode(Ref(fake_data))).WillOnce(Invoke([&](Buffer::Instance&) -> void {
Expand Down Expand Up @@ -884,7 +885,8 @@ TEST(RedisClientFactoryImplTest, Basic) {

// Cluster stats
Stats::IsolatedStoreImpl fake_stats;
RedisClusterStats redis_cluster_stats = RedisClusterStats{REDIS_CLUSTER_STATS(POOL_COUNTER(fake_stats), POOL_HISTOGRAM(fake_stats))};
RedisClusterStats redis_cluster_stats =
RedisClusterStats{REDIS_CLUSTER_STATS(POOL_COUNTER(fake_stats), POOL_HISTOGRAM(fake_stats))};

ClientPtr client = factory.create(host, dispatcher, config, redis_cluster_stats);
client->close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ class RedisConnPoolImplTest : public testing::Test, public Common::Redis::Client

// Common::Redis::Client::ClientFactory
Common::Redis::Client::ClientPtr create(Upstream::HostConstSharedPtr host, Event::Dispatcher&,
const Common::Redis::Client::Config&, Common::Redis::Client::RedisClusterStats&) override {
const Common::Redis::Client::Config&,
Common::Redis::Client::RedisClusterStats&) override {
return Common::Redis::Client::ClientPtr{create_(host)};
}

Expand Down
3 changes: 2 additions & 1 deletion test/extensions/health_checkers/redis/redis_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ class RedisHealthCheckerTest

Extensions::NetworkFilters::Common::Redis::Client::ClientPtr
create(Upstream::HostConstSharedPtr, Event::Dispatcher&,
const Extensions::NetworkFilters::Common::Redis::Client::Config&, Extensions::NetworkFilters::Common::Redis::Client::RedisClusterStats&) override {
const Extensions::NetworkFilters::Common::Redis::Client::Config&,
Extensions::NetworkFilters::Common::Redis::Client::RedisClusterStats&) override {
return Extensions::NetworkFilters::Common::Redis::Client::ClientPtr{create_()};
}

Expand Down

0 comments on commit 35b6128

Please sign in to comment.