diff options
| author | ngc224 <[email protected]> | 2025-06-13 16:17:14 +0300 |
|---|---|---|
| committer | ngc224 <[email protected]> | 2025-06-13 16:43:25 +0300 |
| commit | 5af77c069f798dda36e69d1628c12252a5117702 (patch) | |
| tree | 9c420e49ea050d7ab14a7213e3ce2e3d2e853726 /yt/cpp/mapreduce/interface | |
| parent | ef58752c7f51af2aea1b49df35e4d71f56db95ef (diff) | |
Allow passing ProxyUrlAliasingRules to clients directly
commit_hash:5493d9ed32b24050fa5feb08fe13097302ca0a23
Diffstat (limited to 'yt/cpp/mapreduce/interface')
| -rw-r--r-- | yt/cpp/mapreduce/interface/config.cpp | 25 | ||||
| -rw-r--r-- | yt/cpp/mapreduce/interface/config.h | 8 |
2 files changed, 33 insertions, 0 deletions
diff --git a/yt/cpp/mapreduce/interface/config.cpp b/yt/cpp/mapreduce/interface/config.cpp index cdabeaf3240..901f59fc215 100644 --- a/yt/cpp/mapreduce/interface/config.cpp +++ b/yt/cpp/mapreduce/interface/config.cpp @@ -190,6 +190,30 @@ void TConfig::LoadTimings() HostListUpdateInterval = TDuration::Seconds(60); } +void TConfig::LoadProxyUrlAliasingRules() +{ + TString strConfig = GetEnv("YT_PROXY_URL_ALIASING_CONFIG"); + if (!strConfig) { + return; + } + + NYT::TNode nodeConfig; + + try { + nodeConfig = NodeFromYsonString(strConfig); + Y_ENSURE(nodeConfig.IsMap()); + } catch (const yexception& exc) { + ythrow yexception() + << "Failed to parse YT_PROXY_URL_ALIASING_CONFIG (it must be yson map): " + << exc; + } + + for (const auto& [key, value] : nodeConfig.AsMap()) { + Y_ENSURE(value.IsString(), "Proxy url is not string"); + ProxyUrlAliasingRules.emplace(key, value.AsString()); + } +} + void TConfig::Reset() { Hosts = GetEnv("YT_HOSTS", DefaultHosts); @@ -219,6 +243,7 @@ void TConfig::Reset() LoadToken(); LoadSpec(); LoadTimings(); + LoadProxyUrlAliasingRules(); CacheUploadDeduplicationMode = GetUploadingDeduplicationMode("YT_UPLOAD_DEDUPLICATION", EUploadDeduplicationMode::Host); CacheUploadDeduplicationThreshold = 10_MB; diff --git a/yt/cpp/mapreduce/interface/config.h b/yt/cpp/mapreduce/interface/config.h index 6e6d7b191c2..7aba0ccd60f 100644 --- a/yt/cpp/mapreduce/interface/config.h +++ b/yt/cpp/mapreduce/interface/config.h @@ -9,6 +9,7 @@ #include <util/generic/maybe.h> #include <util/generic/string.h> +#include <util/generic/hash.h> #include <util/generic/hash_set.h> #include <util/datetime/base.h> @@ -111,6 +112,12 @@ struct TConfig /// @brief Represents the role involved in RPC proxy configuration. TString RpcProxyRole; + /// @brief Proxy url aliasing rules to be used for connection. + /// + /// You can pass here "foo" => "fqdn:port" and afterwards use "foo" as handy alias, + /// while all connections will be made to "fqdn:port" address. + THashMap<TString, TString> ProxyUrlAliasingRules; + /// /// For historical reasons mapreduce client uses its own logging system. /// @@ -264,6 +271,7 @@ struct TConfig void LoadToken(); void LoadSpec(); void LoadTimings(); + void LoadProxyUrlAliasingRules(); void Reset(); |
