Skip to content

Commit

Permalink
feat: refractor and resolve pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
marfanr committed Jan 8, 2024
1 parent c07f360 commit e40d1de
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 63 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ament_target_dependencies(${PROJECT_NAME}
tachimawari_interfaces
gRPC)

target_link_libraries(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME}
gRPC::grpc++_reflection
gRPC::grpc++
)
Expand Down
42 changes: 36 additions & 6 deletions include/akushon/config/grpc/call_data.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 Ichiro ITS
// Copyright (c) 2024 Ichiro ITS
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -21,22 +21,23 @@
#ifndef AKUSHON__CONFIG__GRPC__CALL_DATA_HPP_
#define AKUSHON__CONFIG__GRPC__CALL_DATA_HPP_

#include "akushon/config/grpc/call_data_base.hpp"
#include "akushon_interfaces/akushon.grpc.pb.h"
#include "akushon_interfaces/akushon.pb.h"
#include "grpc/support/log.h"
#include "grpcpp/grpcpp.h"
#include "akushon/config/grpc/call_data_base.hpp"

namespace akushon
{
template <class ConfigRequest, class ConfigReply>
class CallData : CallDataBase {
class CallData : CallDataBase
{
public:
CallData(
akushon_interfaces::proto::Config::AsyncService * service, grpc::ServerCompletionQueue * cq,
const std::string& path);
const std::string & path);
void Proceed() override;

protected:
virtual void AddNextToCompletionQueue() = 0;

Expand All @@ -46,14 +47,43 @@ class CallData : CallDataBase {

akushon_interfaces::proto::Config::AsyncService * service_;

const std::string& path_;
const std::string & path_;

grpc::ServerCompletionQueue * cq_;
grpc::ServerContext ctx_;
ConfigRequest request_;
ConfigReply reply_;
grpc::ServerAsyncResponseWriter<ConfigReply> responder_;
};

template <class ConfigRequest, class ConfigReply>
CallData<ConfigRequest, ConfigReply>::CallData(
akushon_interfaces::proto::Config::AsyncService * service, grpc::ServerCompletionQueue * cq,
const std::string & path)
: status_(CallStatus::CREATE), service_(service), cq_(cq), responder_(&ctx_), path_(path)
{
}

template <class ConfigRequest, class ConfigReply>
void CallData<ConfigRequest, ConfigReply>::Proceed()
{
switch (status_) {
case CallStatus::CREATE:
status_ = CallStatus::PROCESS;
WaitForRequest();
break;
case CallStatus::PROCESS:
AddNextToCompletionQueue();
HandleRequest();
status_ = CallStatus::FINISH;
responder_.Finish(reply_, grpc::Status::OK, this);
break;
default:
delete this;
break;
}
}

} // namespace akushon

#endif // AKUSHON__CONFIG__GRPC__CALL_DATA_HPP_
56 changes: 0 additions & 56 deletions src/akushon/config/grpc/call_data.cpp

This file was deleted.

0 comments on commit e40d1de

Please sign in to comment.