Skip to content

Commit

Permalink
Incorporate protobuf stub instead
Browse files Browse the repository at this point in the history
In further version of protobuf stubs are marked as final in sake of
optimization.

Relates #169
  • Loading branch information
GeorgyKirichenko committed Apr 13, 2024
1 parent 617dc45 commit 1c34c7d
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions common/iproto_controlplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand All @@ -50,14 +44,14 @@ 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());
}
}

protected:
common::proto::UnixProtobufRpcChannel* channel;
common::icp_proto::BalancerService::Stub stub;
};
}

0 comments on commit 1c34c7d

Please sign in to comment.