Skip to content

Commit

Permalink
Add comments and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
motxx committed Jul 12, 2017
1 parent e13ed1b commit c92217c
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions irohad/network/grpc_call.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ namespace network {
*/

/**
* to enable various types to process in ServiceHandler::handleRpcs()
*
* to enable various Call instances to process in ServiceHandler::handleRpcs() by polymorphism.
* @tparam ServiceHandler
*/
template <typename ServiceHandler>
Expand All @@ -57,16 +56,21 @@ namespace network {
virtual ~UntypedCall() {}

/**
* selects a procedure by state and invokes it by using polymorphism.
* @param serviceHandler
* invokes when state is RequestReceivedTag.
* @param serviceHandler - an instance that has all rpc handlers. e.g. CommandService
*/
virtual void requestReceived(ServiceHandler& serviceHandler) = 0;

/**
*
* invokes when state is ResponseSentTag.
*/
virtual void responseSent() = 0;

/**
* selects a procedure by state and invokes it by using polymorphism.
* this is called from ServiceHandler::handleRpcs()
* @param serviceHandler - an instance that has all rpc handlers. e.g. CommandService
*/
void onCompleted(ServiceHandler& serviceHandler) {
switch (callback_) {
case State::RequestCreated: {
Expand Down Expand Up @@ -102,26 +106,28 @@ namespace network {
virtual ~Call() {}

/**
* called by onCompleted() in super class.
*
* invokes when state is RequestReceivedTag.
* this method is called by onCompleted() in super class (UntypedCall).
* @param serviceHandler - an instance that has all rpc handlers. e.g. CommandService
*/
void requestReceived(ServiceHandler* serviceHandler) override {
rpcHandler(*this);
}

/**
*
* invokes when state is ResponseSentTag.
* this method is called by onCompleted() in super class (UntypedCall).
* @param serviceHandler - an instance that has all rpc handlers. e.g. CommandService
*/
void responseSent() override {
}

/**
*
* notifies response and grpc::Status when finishing handling rpc.
* @param status
*/
void sendResponse(const ::grpc::Status& status) {
responder_.Finish(response, status, &response_sent_tag_);
responder_.Finish(response, status, &ResponseSentTag);
}

/**
Expand Down

0 comments on commit c92217c

Please sign in to comment.