aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorh0pless <h0pless@yandex-team.com>2023-10-16 13:41:00 +0300
committerh0pless <h0pless@yandex-team.com>2023-10-16 14:10:45 +0300
commit98d6cc064d609c73b9ecd820ff7b21f5200baa85 (patch)
tree1a312e35af9c3cf7bb8ae6372e71ec4d0f563e2d
parent3e240b5ac6fc0bf9515d9cfb7f3d48d40d239f97 (diff)
downloadydb-98d6cc064d609c73b9ecd820ff7b21f5200baa85.tar.gz
Minor refactorings in typehandlers
1. Move typehandler registration from boostrap to cypress manager 2. Move rootstock creation from client side (via typehandler) to cypress proxy 3. Add IsInTransactionAction flag
-rw-r--r--yt/yt/core/rpc/public.h2
-rw-r--r--yt/yt/core/ytree/helpers-inl.h15
-rw-r--r--yt/yt/core/ytree/helpers.h10
3 files changed, 27 insertions, 0 deletions
diff --git a/yt/yt/core/rpc/public.h b/yt/yt/core/rpc/public.h
index 616bfce116..e5fca23b2d 100644
--- a/yt/yt/core/rpc/public.h
+++ b/yt/yt/core/rpc/public.h
@@ -88,6 +88,8 @@ template <
>
class TGenericTypedServiceContext;
+struct THandlerInvocationOptions;
+
class TServiceContextWrapper;
template <class TRequestMessage, class TResponseMessage>
diff --git a/yt/yt/core/ytree/helpers-inl.h b/yt/yt/core/ytree/helpers-inl.h
index 04a4962d0d..ea204ab82b 100644
--- a/yt/yt/core/ytree/helpers-inl.h
+++ b/yt/yt/core/ytree/helpers-inl.h
@@ -130,4 +130,19 @@ IYPathServicePtr IYPathService::FromMethod(
////////////////////////////////////////////////////////////////////////////////
+template <class TReq, class TRsp>
+TIntrusivePtr<TTypedYPathServiceContext<TReq, TRsp>> DeserializeAsTypedOrThrow(
+ const IYPathServiceContextPtr& context,
+ const NRpc::THandlerInvocationOptions& options)
+{
+ auto typedContext = New<TTypedYPathServiceContext<TReq, TRsp>>(context, options);
+ if (!typedContext->DeserializeRequest()) {
+ THROW_ERROR_EXCEPTION("Error deserializing request");
+ }
+
+ return typedContext;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
} // namespace NYT::NYTree
diff --git a/yt/yt/core/ytree/helpers.h b/yt/yt/core/ytree/helpers.h
index 76cb8d2677..489785ea75 100644
--- a/yt/yt/core/ytree/helpers.h
+++ b/yt/yt/core/ytree/helpers.h
@@ -4,6 +4,8 @@
#include <yt/yt/core/misc/serialize.h>
+#include <yt/yt/core/rpc/public.h>
+
#include <yt/yt/core/yson/public.h>
#include <yt/yt_proto/yt/core/ytree/proto/attributes.pb.h>
@@ -56,6 +58,14 @@ std::vector<IAttributeDictionary::TKeyValuePair> ListAttributesPairs(const IAttr
////////////////////////////////////////////////////////////////////////////////
+//! Creates typed context and deserializes it. Throws if deserialization fails.
+template <class TReq, class TRsp>
+TIntrusivePtr<TTypedYPathServiceContext<TReq, TRsp>> DeserializeAsTypedOrThrow(
+ const IYPathServiceContextPtr& context,
+ const NRpc::THandlerInvocationOptions& options);
+
+////////////////////////////////////////////////////////////////////////////////
+
} // namespace NYT::NYTree
namespace NYT {