diff options
author | manainen <manainen@yandex-team.com> | 2023-11-20 13:27:11 +0300 |
---|---|---|
committer | manainen <manainen@yandex-team.com> | 2023-11-20 14:51:07 +0300 |
commit | 9ad18b5d8b192ed599c3888300695e58da311c6f (patch) | |
tree | 77e96320d5aec3750af315e12cf4b5dc8b93e4d1 | |
parent | ffff7a34e41bf0dd7d5e0f3d78aeaebbf56200e6 (diff) | |
download | ydb-9ad18b5d8b192ed599c3888300695e58da311c6f.tar.gz |
Enable hardcode of proxies in a hedging client
added EnableProxyDiscovery parameter to the standard client
-rw-r--r-- | yt/yt/client/api/rpc_proxy/config.cpp | 5 | ||||
-rw-r--r-- | yt/yt/client/api/rpc_proxy/config.h | 1 | ||||
-rw-r--r-- | yt/yt/client/api/rpc_proxy/connection_impl.cpp | 12 | ||||
-rw-r--r-- | yt/yt/client/cache/rpc.cpp | 6 | ||||
-rw-r--r-- | yt/yt_proto/yt/client/cache/proto/config.proto | 3 |
5 files changed, 22 insertions, 5 deletions
diff --git a/yt/yt/client/api/rpc_proxy/config.cpp b/yt/yt/client/api/rpc_proxy/config.cpp index ced3029902..1fbd8eb1f6 100644 --- a/yt/yt/client/api/rpc_proxy/config.cpp +++ b/yt/yt/client/api/rpc_proxy/config.cpp @@ -37,6 +37,8 @@ void TConnectionConfig::Register(TRegistrar registrar) .Optional(); registrar.Parameter("proxy_unix_domain_socket", &TThis::ProxyUnixDomainSocket) .Optional(); + registrar.Parameter("enable_proxy_discovery", &TThis::EnableProxyDiscovery) + .Default(true); registrar.Parameter("dynamic_channel_pool", &TThis::DynamicChannelPool) .DefaultNew(); @@ -120,6 +122,9 @@ void TConnectionConfig::Register(TRegistrar registrar) if (config->ProxyAddresses && config->ProxyAddresses->empty()) { THROW_ERROR_EXCEPTION("\"proxy_addresses\" must not be empty"); } + if (!config->EnableProxyDiscovery && !config->ProxyAddresses) { + THROW_ERROR_EXCEPTION("If proxy discovery is disabled, \"proxy_addresses\" should be specified"); + } if (!config->ClusterName && config->ClusterUrl) { config->ClusterName = InferYTClusterFromClusterUrl(*config->ClusterUrl); diff --git a/yt/yt/client/api/rpc_proxy/config.h b/yt/yt/client/api/rpc_proxy/config.h index 3f3de07185..fd92333c39 100644 --- a/yt/yt/client/api/rpc_proxy/config.h +++ b/yt/yt/client/api/rpc_proxy/config.h @@ -31,6 +31,7 @@ public: std::optional<std::vector<TString>> ProxyAddresses; NRpc::TServiceDiscoveryEndpointsConfigPtr ProxyEndpoints; std::optional<TString> ProxyUnixDomainSocket; + bool EnableProxyDiscovery; NRpc::TDynamicChannelPoolConfigPtr DynamicChannelPool; diff --git a/yt/yt/client/api/rpc_proxy/connection_impl.cpp b/yt/yt/client/api/rpc_proxy/connection_impl.cpp index 11621ea707..11a7347bae 100644 --- a/yt/yt/client/api/rpc_proxy/connection_impl.cpp +++ b/yt/yt/client/api/rpc_proxy/connection_impl.cpp @@ -252,12 +252,14 @@ TConnection::TConnection(TConnectionConfigPtr config, TConnectionOptions options ConnectionInvoker_ = ActionQueue_->GetInvoker(); } - UpdateProxyListExecutor_ = New<TPeriodicExecutor>( - GetInvoker(), - BIND(&TConnection::OnProxyListUpdate, MakeWeak(this)), - TPeriodicExecutorOptions::WithJitter(Config_->ProxyListUpdatePeriod)); + if (Config_->EnableProxyDiscovery) { + UpdateProxyListExecutor_ = New<TPeriodicExecutor>( + GetInvoker(), + BIND(&TConnection::OnProxyListUpdate, MakeWeak(this)), + TPeriodicExecutorOptions::WithJitter(Config_->ProxyListUpdatePeriod)); + } - if (Config_->ProxyEndpoints) { + if (Config_->EnableProxyDiscovery && Config_->ProxyEndpoints) { ServiceDiscovery_ = NRpc::TDispatcher::Get()->GetServiceDiscovery(); if (!ServiceDiscovery_) { ChannelPool_->SetPeerDiscoveryError(TError("No Service Discovery is configured")); diff --git a/yt/yt/client/cache/rpc.cpp b/yt/yt/client/cache/rpc.cpp index 1af59b48c9..e4cd222d06 100644 --- a/yt/yt/client/cache/rpc.cpp +++ b/yt/yt/client/cache/rpc.cpp @@ -45,6 +45,12 @@ NApi::NRpcProxy::TConnectionConfigPtr GetConnectionConfig(const TConfig& config) if (config.GetModifyRowsBatchCapacity() != 0) { connectionConfig->ModifyRowsBatchCapacity = config.GetModifyRowsBatchCapacity(); } + if (config.HasEnableProxyDiscovery()) { + connectionConfig->EnableProxyDiscovery = config.GetEnableProxyDiscovery(); + } + if (!config.GetProxyAddresses().empty()) { + connectionConfig->ProxyAddresses = std::vector<TString>(config.GetProxyAddresses().begin(), config.GetProxyAddresses().end()); + } #define SET_TIMEOUT_OPTION(name) \ if (config.Get##name() != 0) connectionConfig->name = TDuration::MilliSeconds(config.Get ## name()) diff --git a/yt/yt_proto/yt/client/cache/proto/config.proto b/yt/yt_proto/yt/client/cache/proto/config.proto index cbaf804ce8..cbaf674a54 100644 --- a/yt/yt_proto/yt/client/cache/proto/config.proto +++ b/yt/yt_proto/yt/client/cache/proto/config.proto @@ -34,6 +34,9 @@ message TConfig optional uint32 RetryBackoffTime = 14; optional uint32 RetryAttempts = 15; optional uint32 RetryTimeout = 16; + + repeated string ProxyAddresses = 17; + optional bool EnableProxyDiscovery = 18; } message TClustersConfig |