|
| 1 | +#include <ydb-cpp-sdk/client/debug/client.h> |
| 2 | + |
| 3 | +#include <src/api/grpc/ydb_debug_v1.grpc.pb.h> |
| 4 | +#include <src/api/grpc/ydb_debug_v1.pb.h> |
| 5 | +#include <src/api/protos/ydb_debug.pb.h> |
| 6 | + |
| 7 | +#define INCLUDE_YDB_INTERNAL_H |
| 8 | +#include <src/client/impl/ydb_internal/make_request/make.h> |
| 9 | +#undef INCLUDE_YDB_INTERNAL_H |
| 10 | + |
| 11 | +#include <src/client/common_client/impl/client.h> |
| 12 | + |
| 13 | +namespace NYdb::NDebug { |
| 14 | + |
| 15 | +using namespace Ydb; |
| 16 | + |
| 17 | +using namespace NThreading; |
| 18 | + |
| 19 | +class TDebugClient::TImpl: public TClientImplCommon<TDebugClient::TImpl> { |
| 20 | +public: |
| 21 | + TImpl(std::shared_ptr<TGRpcConnectionsImpl>&& connections, const TClientSettings& settings) |
| 22 | + : TClientImplCommon(std::move(connections), settings) |
| 23 | + {} |
| 24 | + |
| 25 | + template<typename TRequest, typename TResponse, typename TResult, typename TSettings> |
| 26 | + auto Ping(const TSettings& settings, auto serviceMethod) { |
| 27 | + auto pingPromise = NewPromise<TResult>(); |
| 28 | + auto responseCb = [pingPromise] (TResponse*, TPlainStatus status) mutable { |
| 29 | + TResult val(TStatus(std::move(status))); |
| 30 | + pingPromise.SetValue(std::move(val)); |
| 31 | + }; |
| 32 | + |
| 33 | + Connections_->Run<Debug::V1::DebugService, TRequest, TResponse>( |
| 34 | + TRequest(), |
| 35 | + responseCb, |
| 36 | + serviceMethod, |
| 37 | + DbDriverState_, |
| 38 | + TRpcRequestSettings::Make(settings)); |
| 39 | + |
| 40 | + return pingPromise; |
| 41 | + } |
| 42 | + |
| 43 | + ~TImpl() = default; |
| 44 | +}; |
| 45 | + |
| 46 | +TDebugClient::TDebugClient(const TDriver& driver, const TClientSettings& settings) |
| 47 | + : Impl_(new TImpl(CreateInternalInterface(driver), settings)) |
| 48 | +{ |
| 49 | +} |
| 50 | + |
| 51 | +TAsyncPlainGrpcPingResult TDebugClient::PingPlainGrpc(const TPlainGrpcPingSettings& settings) { |
| 52 | + return Impl_->Ping<Debug::PlainGrpcRequest, Debug::PlainGrpcResponse, TPlainGrpcPingResult>( |
| 53 | + settings, &Debug::V1::DebugService::Stub::AsyncPingPlainGrpc); |
| 54 | +} |
| 55 | + |
| 56 | +TAsyncGrpcProxyPingResult TDebugClient::PingGrpcProxy(const TGrpcProxyPingSettings& settings) { |
| 57 | + return Impl_->Ping<Debug::GrpcProxyRequest, Debug::GrpcProxyResponse, TGrpcProxyPingResult>( |
| 58 | + settings, &Debug::V1::DebugService::Stub::AsyncPingGrpcProxy); |
| 59 | +} |
| 60 | + |
| 61 | +TAsyncKqpProxyPingResult TDebugClient::PingKqpProxy(const TKqpProxyPingSettings& settings) { |
| 62 | + return Impl_->Ping<Debug::KqpProxyRequest, Debug::KqpProxyResponse, TKqpProxyPingResult>( |
| 63 | + settings, &Debug::V1::DebugService::Stub::AsyncPingKqpProxy); |
| 64 | +} |
| 65 | + |
| 66 | +TAsyncSchemeCachePingResult TDebugClient::PingSchemeCache(const TSchemeCachePingSettings& settings) { |
| 67 | + return Impl_->Ping<Debug::SchemeCacheRequest, Debug::SchemeCacheResponse, TSchemeCachePingResult>( |
| 68 | + settings, &Debug::V1::DebugService::Stub::AsyncPingSchemeCache); |
| 69 | +} |
| 70 | + |
| 71 | +TAsyncTxProxyPingResult TDebugClient::PingTxProxy(const TTxProxyPingSettings& settings) { |
| 72 | + return Impl_->Ping<Debug::TxProxyRequest, Debug::TxProxyResponse, TTxProxyPingResult>( |
| 73 | + settings, &Debug::V1::DebugService::Stub::AsyncPingTxProxy); |
| 74 | +} |
| 75 | + |
| 76 | +} // namespace NYdb::NDebug |
0 commit comments