From 1c34c7d0ea10a55cf41f8fcb9459f8c646be12bd Mon Sep 17 00:00:00 2001 From: Georgy Kirichenko Date: Sun, 24 Dec 2023 22:15:44 +0300 Subject: [PATCH] Incorporate protobuf stub instead In further version of protobuf stubs are marked as final in sake of optimization. Relates #169 --- common/iproto_controlplane.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/common/iproto_controlplane.h b/common/iproto_controlplane.h index 909a03f4..23246296 100644 --- a/common/iproto_controlplane.h +++ b/common/iproto_controlplane.h @@ -8,26 +8,20 @@ namespace interface { -class protoControlPlane : protected common::icp_proto::BalancerService::Stub +class protoControlPlane { public: protoControlPlane(common::proto::UnixProtobufRpcChannel* channel = new common::proto::UnixProtobufRpcChannel(common::icp_proto::socketPath)) : - common::icp_proto::BalancerService::Stub(channel), - channel(channel) + stub(channel) { } - ~protoControlPlane() override - { - delete channel; - } - auto balancer_real_flush() { common::icp_proto::Empty request; common::proto::RpcController ctl; common::icp_proto::Empty response; - RealFlush(&ctl, &request, &response, nullptr); + stub.RealFlush(&ctl, &request, &response, nullptr); if (ctl.Failed()) { throw std::string("rpc error: " + ctl.ErrorText()); @@ -38,7 +32,7 @@ class protoControlPlane : protected common::icp_proto::BalancerService::Stub { common::proto::RpcController ctl; common::icp_proto::BalancerRealFindResponse response; - RealFind(&ctl, &request, &response, nullptr); + stub.RealFind(&ctl, &request, &response, nullptr); if (ctl.Failed()) { throw std::string("rpc error: " + ctl.ErrorText()); @@ -50,7 +44,7 @@ class protoControlPlane : protected common::icp_proto::BalancerService::Stub { common::proto::RpcController ctl; common::icp_proto::Empty response; - Real(&ctl, &request, &response, nullptr); + stub.Real(&ctl, &request, &response, nullptr); if (ctl.Failed()) { throw std::string("rpc error: " + ctl.ErrorText()); @@ -58,6 +52,6 @@ class protoControlPlane : protected common::icp_proto::BalancerService::Stub } protected: - common::proto::UnixProtobufRpcChannel* channel; + common::icp_proto::BalancerService::Stub stub; }; }