diff options
author | innokentii <innokentii@yandex-team.com> | 2023-03-08 11:20:29 +0300 |
---|---|---|
committer | innokentii <innokentii@yandex-team.com> | 2023-03-08 11:20:29 +0300 |
commit | 75edce8ac1d79dafcb198fe50d7d97819b2c0ece (patch) | |
tree | f9d96bec28d7c5847826e703ae68f9c42018dbf5 | |
parent | f66e47cd2b45c5afb5307447837ec9b2dae1cbe6 (diff) | |
download | ydb-75edce8ac1d79dafcb198fe50d7d97819b2c0ece.tar.gz |
Add basic yaml cluster-config api impl
add basic yaml cluster-config api impl
13 files changed, 500 insertions, 0 deletions
diff --git a/ydb/public/api/grpc/draft/CMakeLists.darwin-x86_64.txt b/ydb/public/api/grpc/draft/CMakeLists.darwin-x86_64.txt index 0f714bbe44..65f2e63d41 100644 --- a/ydb/public/api/grpc/draft/CMakeLists.darwin-x86_64.txt +++ b/ydb/public/api/grpc/draft/CMakeLists.darwin-x86_64.txt @@ -108,6 +108,18 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) +get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) add_library(api-grpc-draft) set_property(TARGET api-grpc-draft PROPERTY @@ -129,6 +141,7 @@ target_proto_messages(api-grpc-draft PRIVATE ${CMAKE_SOURCE_DIR}/ydb/public/api/grpc/draft/ydb_long_tx_v1.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/grpc/draft/ydb_logstore_v1.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/grpc/draft/ydb_query_v1.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/grpc/draft/ydb_console_v1.proto ) target_proto_addincls(api-grpc-draft ./ diff --git a/ydb/public/api/grpc/draft/CMakeLists.linux-aarch64.txt b/ydb/public/api/grpc/draft/CMakeLists.linux-aarch64.txt index 93c8649f4f..164d75d0d3 100644 --- a/ydb/public/api/grpc/draft/CMakeLists.linux-aarch64.txt +++ b/ydb/public/api/grpc/draft/CMakeLists.linux-aarch64.txt @@ -108,6 +108,18 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) +get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) add_library(api-grpc-draft) set_property(TARGET api-grpc-draft PROPERTY @@ -130,6 +142,7 @@ target_proto_messages(api-grpc-draft PRIVATE ${CMAKE_SOURCE_DIR}/ydb/public/api/grpc/draft/ydb_long_tx_v1.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/grpc/draft/ydb_logstore_v1.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/grpc/draft/ydb_query_v1.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/grpc/draft/ydb_console_v1.proto ) target_proto_addincls(api-grpc-draft ./ diff --git a/ydb/public/api/grpc/draft/CMakeLists.linux-x86_64.txt b/ydb/public/api/grpc/draft/CMakeLists.linux-x86_64.txt index 93c8649f4f..164d75d0d3 100644 --- a/ydb/public/api/grpc/draft/CMakeLists.linux-x86_64.txt +++ b/ydb/public/api/grpc/draft/CMakeLists.linux-x86_64.txt @@ -108,6 +108,18 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) +get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) add_library(api-grpc-draft) set_property(TARGET api-grpc-draft PROPERTY @@ -130,6 +142,7 @@ target_proto_messages(api-grpc-draft PRIVATE ${CMAKE_SOURCE_DIR}/ydb/public/api/grpc/draft/ydb_long_tx_v1.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/grpc/draft/ydb_logstore_v1.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/grpc/draft/ydb_query_v1.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/grpc/draft/ydb_console_v1.proto ) target_proto_addincls(api-grpc-draft ./ diff --git a/ydb/public/api/grpc/draft/ydb_console_v1.proto b/ydb/public/api/grpc/draft/ydb_console_v1.proto new file mode 100644 index 0000000000..81b1be840a --- /dev/null +++ b/ydb/public/api/grpc/draft/ydb_console_v1.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +option cc_enable_arenas = true; + +package Ydb.Console.V1; + +option java_package = "com.yandex.ydb.console.v1"; + +import "ydb/public/api/protos/draft/ydb_console.proto"; + +service ConsoleService { + rpc ApplyConfig(Console.ApplyConfigRequest) returns (Console.ApplyConfigResponse); + rpc AddVolatileConfig(Console.AddVolatileConfigRequest) returns (Console.AddVolatileConfigResponse); + rpc RemoveVolatileConfig(Console.RemoveVolatileConfigRequest) returns (Console.RemoveVolatileConfigResponse); + rpc GetConfig(Console.GetConfigRequest) returns (Console.GetConfigResponse); + rpc ResolveConfig(Console.ResolveConfigRequest) returns (Console.ResolveConfigResponse); + rpc ResolveAllConfig(Console.ResolveAllConfigRequest) returns (Console.ResolveAllConfigResponse); +} diff --git a/ydb/public/api/protos/CMakeLists.darwin-x86_64.txt b/ydb/public/api/protos/CMakeLists.darwin-x86_64.txt index 73f526785d..f58201924d 100644 --- a/ydb/public/api/protos/CMakeLists.darwin-x86_64.txt +++ b/ydb/public/api/protos/CMakeLists.darwin-x86_64.txt @@ -387,6 +387,18 @@ get_built_tool_path( cpp_styleguide ) get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) +get_built_tool_path( TOOL_enum_parser_bin TOOL_enum_parser_dependency tools/enum_parser/enum_parser @@ -427,6 +439,7 @@ target_proto_messages(api-protos PRIVATE ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/draft/ydb_long_tx.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/draft/ydb_logstore.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/draft/ydb_query.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/draft/ydb_console.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/persqueue_error_codes_v1.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/ydb_auth.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/ydb_persqueue_v1.proto diff --git a/ydb/public/api/protos/CMakeLists.linux-aarch64.txt b/ydb/public/api/protos/CMakeLists.linux-aarch64.txt index c04805976d..99971e435d 100644 --- a/ydb/public/api/protos/CMakeLists.linux-aarch64.txt +++ b/ydb/public/api/protos/CMakeLists.linux-aarch64.txt @@ -387,6 +387,18 @@ get_built_tool_path( cpp_styleguide ) get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) +get_built_tool_path( TOOL_enum_parser_bin TOOL_enum_parser_dependency tools/enum_parser/enum_parser @@ -428,6 +440,7 @@ target_proto_messages(api-protos PRIVATE ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/draft/ydb_long_tx.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/draft/ydb_logstore.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/draft/ydb_query.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/draft/ydb_console.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/persqueue_error_codes_v1.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/ydb_auth.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/ydb_persqueue_v1.proto diff --git a/ydb/public/api/protos/CMakeLists.linux-x86_64.txt b/ydb/public/api/protos/CMakeLists.linux-x86_64.txt index c04805976d..99971e435d 100644 --- a/ydb/public/api/protos/CMakeLists.linux-x86_64.txt +++ b/ydb/public/api/protos/CMakeLists.linux-x86_64.txt @@ -387,6 +387,18 @@ get_built_tool_path( cpp_styleguide ) get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) +get_built_tool_path( TOOL_enum_parser_bin TOOL_enum_parser_dependency tools/enum_parser/enum_parser @@ -428,6 +440,7 @@ target_proto_messages(api-protos PRIVATE ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/draft/ydb_long_tx.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/draft/ydb_logstore.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/draft/ydb_query.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/draft/ydb_console.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/persqueue_error_codes_v1.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/ydb_auth.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/protos/ydb_persqueue_v1.proto diff --git a/ydb/public/api/protos/draft/ydb_console.proto b/ydb/public/api/protos/draft/ydb_console.proto new file mode 100644 index 0000000000..c468ec51b7 --- /dev/null +++ b/ydb/public/api/protos/draft/ydb_console.proto @@ -0,0 +1,82 @@ +syntax = "proto3"; +option cc_enable_arenas = true; + +package Ydb.Console; +option java_package = "com.yandex.ydb.console"; + +import "ydb/public/api/protos/ydb_operation.proto"; + +message ApplyConfigRequest { + Ydb.Operations.OperationParams operation_params = 1; + optional string config = 2; +} + +message ApplyConfigResponse { + Ydb.Operations.Operation operation = 1; +} + +message AddVolatileConfigRequest { + Ydb.Operations.OperationParams operation_params = 1; + optional uint64 id = 2; + optional string config = 3; + optional uint64 version = 4; + optional string cluster = 5; +} + +message AddVolatileConfigResponse { + Ydb.Operations.Operation operation = 1; +} + +message VolatileConfig { + optional uint64 id = 1; + optional string config = 2; +} + +message GetConfigRequest { + Ydb.Operations.OperationParams operation_params = 1; +} + +message GetConfigResponse { + Ydb.Operations.Operation operation = 1; + optional string config = 2; + repeated VolatileConfig volatile_configs = 3; + optional string cluster = 4; + optional uint32 version = 5; +} + +message RemoveVolatileConfigRequest { + Ydb.Operations.OperationParams operation_params = 1; + repeated uint64 ids = 2; +} + +message RemoveVolatileConfigResponse { + Ydb.Operations.Operation operation = 1; +} + +message YamlLabel { + optional string label = 1; + optional string value = 2; +} + +message ResolveConfigRequest { + Ydb.Operations.OperationParams operation_params = 1; + optional string config = 2; + repeated VolatileConfig volatile_configs = 3; + repeated YamlLabel labels = 4; +} + +message ResolveConfigResponse { + Ydb.Operations.Operation operation = 1; + optional string config = 2; +} + +message ResolveAllConfigRequest { + Ydb.Operations.OperationParams operation_params = 1; + optional string config = 2; + repeated VolatileConfig volatile_configs = 3; +} + +message ResolveAllConfigResponse { + Ydb.Operations.Operation operation = 1; + optional string config = 2; +} diff --git a/ydb/public/sdk/cpp/client/draft/CMakeLists.darwin-x86_64.txt b/ydb/public/sdk/cpp/client/draft/CMakeLists.darwin-x86_64.txt index 5697958846..6dd4616388 100644 --- a/ydb/public/sdk/cpp/client/draft/CMakeLists.darwin-x86_64.txt +++ b/ydb/public/sdk/cpp/client/draft/CMakeLists.darwin-x86_64.txt @@ -19,6 +19,7 @@ target_link_libraries(cpp-client-draft PUBLIC cpp-client-ydb_value ) target_sources(cpp-client-draft PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/public/sdk/cpp/client/draft/ydb_console.cpp ${CMAKE_SOURCE_DIR}/ydb/public/sdk/cpp/client/draft/ydb_scripting.cpp ${CMAKE_SOURCE_DIR}/ydb/public/sdk/cpp/client/draft/ydb_long_tx.cpp ) diff --git a/ydb/public/sdk/cpp/client/draft/CMakeLists.linux-aarch64.txt b/ydb/public/sdk/cpp/client/draft/CMakeLists.linux-aarch64.txt index a3c961c33e..4fb6dbc405 100644 --- a/ydb/public/sdk/cpp/client/draft/CMakeLists.linux-aarch64.txt +++ b/ydb/public/sdk/cpp/client/draft/CMakeLists.linux-aarch64.txt @@ -20,6 +20,7 @@ target_link_libraries(cpp-client-draft PUBLIC cpp-client-ydb_value ) target_sources(cpp-client-draft PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/public/sdk/cpp/client/draft/ydb_console.cpp ${CMAKE_SOURCE_DIR}/ydb/public/sdk/cpp/client/draft/ydb_scripting.cpp ${CMAKE_SOURCE_DIR}/ydb/public/sdk/cpp/client/draft/ydb_long_tx.cpp ) diff --git a/ydb/public/sdk/cpp/client/draft/CMakeLists.linux-x86_64.txt b/ydb/public/sdk/cpp/client/draft/CMakeLists.linux-x86_64.txt index a3c961c33e..4fb6dbc405 100644 --- a/ydb/public/sdk/cpp/client/draft/CMakeLists.linux-x86_64.txt +++ b/ydb/public/sdk/cpp/client/draft/CMakeLists.linux-x86_64.txt @@ -20,6 +20,7 @@ target_link_libraries(cpp-client-draft PUBLIC cpp-client-ydb_value ) target_sources(cpp-client-draft PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/public/sdk/cpp/client/draft/ydb_console.cpp ${CMAKE_SOURCE_DIR}/ydb/public/sdk/cpp/client/draft/ydb_scripting.cpp ${CMAKE_SOURCE_DIR}/ydb/public/sdk/cpp/client/draft/ydb_long_tx.cpp ) diff --git a/ydb/public/sdk/cpp/client/draft/ydb_console.cpp b/ydb/public/sdk/cpp/client/draft/ydb_console.cpp new file mode 100644 index 0000000000..e72a0ea291 --- /dev/null +++ b/ydb/public/sdk/cpp/client/draft/ydb_console.cpp @@ -0,0 +1,198 @@ +#include "ydb_console.h" + +#include <ydb/public/sdk/cpp/client/ydb_common_client/impl/client.h> +#include <ydb/public/sdk/cpp/client/impl/ydb_internal/make_request/make.h> + +namespace NYdb::NConsole { + +class TConsoleClient::TImpl : public TClientImplCommon<TConsoleClient::TImpl> { +public: + TImpl(std::shared_ptr<TGRpcConnectionsImpl> connections) + : TClientImplCommon(std::move(connections), TConsoleClientSettings{}) + { + } + + TAsyncStatus ApplyConfig(const TString& config, const TClusterConfigSettings& settings = {}) { + auto request = MakeOperationRequest<Ydb::Console::ApplyConfigRequest>(settings); + request.set_config(config); + + return RunSimple<Ydb::Console::V1::ConsoleService, Ydb::Console::ApplyConfigRequest, Ydb::Console::ApplyConfigResponse>( + std::move(request), + &Ydb::Console::V1::ConsoleService::Stub::AsyncApplyConfig, + TRpcRequestSettings::Make(settings)); + } + + TAsyncStatus AddVolatileConfig(const TString& config, ui64 id, ui64 version, const TString& cluster, const TClusterConfigSettings& settings = {}) { + auto request = MakeOperationRequest<Ydb::Console::AddVolatileConfigRequest>(settings); + request.set_config(config); + request.set_id(id); + request.set_version(version); + request.set_cluster(cluster); + + return RunSimple<Ydb::Console::V1::ConsoleService, Ydb::Console::AddVolatileConfigRequest, Ydb::Console::AddVolatileConfigResponse>( + std::move(request), + &Ydb::Console::V1::ConsoleService::Stub::AsyncAddVolatileConfig, + TRpcRequestSettings::Make(settings)); + } + + TAsyncStatus RemoveVolatileConfig(const TVector<ui64>& ids, const TClusterConfigSettings& settings = {}) { + auto request = MakeOperationRequest<Ydb::Console::RemoveVolatileConfigRequest>(settings); + for (auto& id: ids) { + request.add_ids(id); + } + + return RunSimple<Ydb::Console::V1::ConsoleService, Ydb::Console::RemoveVolatileConfigRequest, Ydb::Console::RemoveVolatileConfigResponse>( + std::move(request), + &Ydb::Console::V1::ConsoleService::Stub::AsyncRemoveVolatileConfig, + TRpcRequestSettings::Make(settings)); + } + + TAsyncGetConfigResult GetConfig(const TClusterConfigSettings& settings = {}) { + auto request = MakeOperationRequest<Ydb::Console::GetConfigRequest>(settings); + + auto promise = NThreading::NewPromise<TGetConfigResult>(); + + auto extractor = [promise] (google::protobuf::Any* any, TPlainStatus status) mutable { + TString clusterName = "<unknown>"; + ui64 version = 0; + TString config; + TMap<ui64, TString> volatileConfigs; + if (Ydb::Console::GetConfigResponse result; any && any->UnpackTo(&result)) { + clusterName = result.cluster(); + version = result.version(); + config = result.config(); + for (const auto& config : result.volatile_configs()) { + volatileConfigs.emplace(config.id(), config.config()); + } + } + + TGetConfigResult val(TStatus(std::move(status)), std::move(clusterName), version, std::move(config), std::move(volatileConfigs)); + promise.SetValue(std::move(val)); + }; + + Connections_->RunDeferred<Ydb::Console::V1::ConsoleService, Ydb::Console::GetConfigRequest, Ydb::Console::GetConfigResponse>( + std::move(request), + extractor, + &Ydb::Console::V1::ConsoleService::Stub::AsyncGetConfig, + DbDriverState_, + INITIAL_DEFERRED_CALL_DELAY, + TRpcRequestSettings::Make(settings)); + + return promise.GetFuture(); + } + + TAsyncResolveConfigResult ResolveConfig(const TString& config, const TMap<ui64, TString>& volatileConfigs, const TMap<TString, TString>& labels, const TClusterConfigSettings& settings = {}) { + auto request = MakeOperationRequest<Ydb::Console::ResolveConfigRequest>(settings); + request.set_config(config); + for (auto& [id, volatileConfig] : volatileConfigs) { + auto* proto = request.add_volatile_configs(); + proto->set_id(id); + proto->set_config(volatileConfig); + } + for (auto& [name, value] : labels) { + auto* proto = request.add_labels(); + proto->set_label(name); + proto->set_value(value); + } + + auto promise = NThreading::NewPromise<TResolveConfigResult>(); + + auto extractor = [promise] (google::protobuf::Any* any, TPlainStatus status) mutable { + TString config; + if (Ydb::Console::ResolveConfigResponse result; any && any->UnpackTo(&result)) { + config = result.config(); + } + + TResolveConfigResult val(TStatus(std::move(status)), std::move(config)); + promise.SetValue(std::move(val)); + }; + + Connections_->RunDeferred<Ydb::Console::V1::ConsoleService, Ydb::Console::ResolveConfigRequest, Ydb::Console::ResolveConfigResponse>( + std::move(request), + extractor, + &Ydb::Console::V1::ConsoleService::Stub::AsyncResolveConfig, + DbDriverState_, + INITIAL_DEFERRED_CALL_DELAY, + TRpcRequestSettings::Make(settings)); + + return promise.GetFuture(); + } + + TAsyncResolveConfigResult ResolveConfig(const TString& config, const TMap<ui64, TString>& volatileConfigs, const TClusterConfigSettings& settings = {}) { + auto request = MakeOperationRequest<Ydb::Console::ResolveAllConfigRequest>(settings); + request.set_config(config); + for (auto& [id, volatileConfig] : volatileConfigs) { + auto* proto = request.add_volatile_configs(); + proto->set_id(id); + proto->set_config(volatileConfig); + } + + auto promise = NThreading::NewPromise<TResolveConfigResult>(); + + auto extractor = [promise] (google::protobuf::Any* any, TPlainStatus status) mutable { + TString config; + if (Ydb::Console::ResolveAllConfigResponse result; any && any->UnpackTo(&result)) { + config = result.config(); + } + + TResolveConfigResult val(TStatus(std::move(status)), std::move(config)); + promise.SetValue(std::move(val)); + }; + + Connections_->RunDeferred<Ydb::Console::V1::ConsoleService, Ydb::Console::ResolveAllConfigRequest, Ydb::Console::ResolveAllConfigResponse>( + std::move(request), + extractor, + &Ydb::Console::V1::ConsoleService::Stub::AsyncResolveAllConfig, + DbDriverState_, + INITIAL_DEFERRED_CALL_DELAY, + TRpcRequestSettings::Make(settings)); + + return promise.GetFuture(); + } +}; + +TConsoleClient::TConsoleClient(const TDriver& driver) + : Impl_(new TConsoleClient::TImpl(CreateInternalInterface(driver))) +{} + +TAsyncStatus TConsoleClient::ApplyConfig( + const TString& config, + const TClusterConfigSettings& settings) { + return Impl_->ApplyConfig(config, settings); +} + +TAsyncStatus TConsoleClient::AddVolatileConfig( + const TString& config, + ui64 id, + ui64 version, + const TString& cluster, + const TClusterConfigSettings& settings) { + return Impl_->AddVolatileConfig(config, id, version, cluster, settings); +} + +TAsyncStatus TConsoleClient::RemoveVolatileConfig( + const TVector<ui64>& ids, + const TClusterConfigSettings& settings) { + return Impl_->RemoveVolatileConfig(ids, settings); +} + +TAsyncGetConfigResult TConsoleClient::GetConfig(const TClusterConfigSettings& settings) { + return Impl_->GetConfig(settings); +} + +TAsyncResolveConfigResult TConsoleClient::ResolveConfig( + const TString& config, + const TMap<ui64, TString>& volatileConfigs, + const TMap<TString, TString>& labels, + const TClusterConfigSettings& settings) { + return Impl_->ResolveConfig(config, volatileConfigs, labels, settings); +} + +TAsyncResolveConfigResult TConsoleClient::ResolveConfig( + const TString& config, + const TMap<ui64, TString>& volatileConfigs, + const TClusterConfigSettings& settings) { + return Impl_->ResolveConfig(config, volatileConfigs, settings); +} + +} // namespace NYdb::NConsole diff --git a/ydb/public/sdk/cpp/client/draft/ydb_console.h b/ydb/public/sdk/cpp/client/draft/ydb_console.h new file mode 100644 index 0000000000..3e298b551d --- /dev/null +++ b/ydb/public/sdk/cpp/client/draft/ydb_console.h @@ -0,0 +1,122 @@ +#pragma once + +#include <ydb/public/api/grpc/draft/ydb_console_v1.grpc.pb.h> +#include <ydb/public/sdk/cpp/client/ydb_types/ydb.h> +#include <ydb/public/sdk/cpp/client/ydb_types/status/status.h> +#include <ydb/public/sdk/cpp/client/ydb_common_client/settings.h> +#include <ydb/public/sdk/cpp/client/ydb_types/request_settings.h> +#include <ydb/public/sdk/cpp/client/ydb_driver/driver.h> + +#include <util/generic/string.h> +#include <util/generic/map.h> +#include <util/system/types.h> + +#include <memory> + +namespace NYdb::NConsole { + +struct TGetConfigResult : public TStatus { + TGetConfigResult( + TStatus status, + TString clusterName, + ui64 version, + TString config, + TMap<ui64, TString> volatileConfigs) + : TStatus(std::move(status)) + , ClusterName_(std::move(clusterName)) + , Version_(version) + , Config_(std::move(config)) + , VolatileConfigs_(std::move(volatileConfigs)) + {} + + const TString& GetClusterName() const { + return ClusterName_; + } + + ui64 GetVersion() const { + return Version_; + } + + const TString& GetConfig() const { + return Config_; + } + + const TMap<ui64, TString>& GetVolatileConfigs() const { + return VolatileConfigs_; + } + +private: + TString ClusterName_; + ui64 Version_; + TString Config_; + TMap<ui64, TString> VolatileConfigs_; +}; + +using TAsyncGetConfigResult = NThreading::TFuture<TGetConfigResult>; + +struct TResolveConfigResult : public TStatus { + TResolveConfigResult( + TStatus status, + TString config) + : TStatus(std::move(status)) + , Config_(std::move(config)) + {} + + const TString& GetConfig() const { + return Config_; + } + +private: + TString Config_; +}; + +using TAsyncResolveConfigResult = NThreading::TFuture<TResolveConfigResult>; + +struct TConsoleClientSettings : public TCommonClientSettingsBase<TConsoleClientSettings> { + using TSelf = TConsoleClientSettings; +}; + +struct TClusterConfigSettings : public NYdb::TOperationRequestSettings<TClusterConfigSettings> {}; + +class TConsoleClient { +public: + class TImpl; + + explicit TConsoleClient(const TDriver& driver); + + // Apply config + TAsyncStatus ApplyConfig(const TString& config, const TClusterConfigSettings& settings = {}); + + // Add volatile config + TAsyncStatus AddVolatileConfig( + const TString& config, + ui64 id, ui64 version, + const TString& cluster, + const TClusterConfigSettings& settings = {}); + + // Remove specific volatile config or all of them + TAsyncStatus RemoveVolatileConfig( + const TVector<ui64>& ids, + const TClusterConfigSettings& settings = {}); + + // Get current cluster configs + TAsyncGetConfigResult GetConfig(const TClusterConfigSettings& settings = {}); + + // Resolve arbitrary config for specific labels + TAsyncResolveConfigResult ResolveConfig( + const TString& config, + const TMap<ui64, TString>& volatileConfigs, + const TMap<TString, TString>& labels, + const TClusterConfigSettings& settings = {}); + + // Resolve arbitrary config for all label combinations + TAsyncResolveConfigResult ResolveConfig( + const TString& config, + const TMap<ui64, TString>& volatileConfigs, + const TClusterConfigSettings& settings = {}); + +private: + std::shared_ptr<TImpl> Impl_; +}; + +} // namespace NYdb::NConsole |