LogCabin
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Friends
LogCabin::Client::LeaderRPCBase::Call Class Reference

An asynchronous version of call(). More...

#include <LeaderRPC.h>

Inheritance diagram for LogCabin::Client::LeaderRPCBase::Call:
LogCabin::Client::anonymous_namespace{MockClientImpl.cc}::TreeLeaderRPC::Call LogCabin::Client::LeaderRPC::Call LogCabin::Client::LeaderRPCMock::Call

List of all members.

Public Types

enum  Status {
  OK,
  RETRY,
  TIMEOUT,
  INVALID_REQUEST
}
 Return type for LeaderRPCBase::Call::wait(). More...

Public Member Functions

 Call ()
 Constructor.
virtual ~Call ()
 Destructor.
virtual void start (OpCode opCode, const google::protobuf::Message &request, TimePoint timeout)=0
 Invoke the RPC.
virtual void cancel ()=0
 Cancel the RPC.
virtual Status wait (google::protobuf::Message &response, TimePoint timeout)=0
 Wait for the RPC to complete.

Friends

std::ostream & operator<< (std::ostream &os, const Status &server)
 Print out a Status for debugging purposes.

Detailed Description

An asynchronous version of call().

This allows multiple RPCs to be executed concurrently, or canceling an RPC that is running on a separate thread.

Definition at line 129 of file LeaderRPC.h.


Member Enumeration Documentation

Return type for LeaderRPCBase::Call::wait().

Enumerator:
OK 

The RPC completed scucessfully.

RETRY 

The RPC did not succeed, nor did it timeout.

The caller should try again. TODO(ongaro): this is a bit ugly

TIMEOUT 

The given timeout elapsed before the RPC completed.

INVALID_REQUEST 

The server rejected the request, probably because it doesn't support the opcode, or maybe the request arguments were invalid.

Definition at line 134 of file LeaderRPC.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 165 of file LeaderRPC.h.

virtual LogCabin::Client::LeaderRPCBase::Call::~Call ( ) [inline, virtual]

Destructor.

Reimplemented in LogCabin::Client::LeaderRPC::Call.

Definition at line 169 of file LeaderRPC.h.


Member Function Documentation

virtual void LogCabin::Client::LeaderRPCBase::Call::start ( OpCode  opCode,
const google::protobuf::Message &  request,
TimePoint  timeout 
) [pure virtual]

Invoke the RPC.

Parameters:
opCodeRPC operation code. The caller must guarantee that this is a valid opCode. (If the server rejects it, this will PANIC.)
requestThe parameters for the operation. The caller must guarantee that this is a well-formed request. (If the server rejects it, this will PANIC.)
timeoutAfter this time has elapsed, stop trying to initiate the connection to the leader and use an invalid session, which will cause the RPC to fail later.

Implemented in LogCabin::Client::LeaderRPC::Call, LogCabin::Client::anonymous_namespace{MockClientImpl.cc}::TreeLeaderRPC::Call, and LogCabin::Client::LeaderRPCMock::Call.

virtual void LogCabin::Client::LeaderRPCBase::Call::cancel ( ) [pure virtual]

Cancel the RPC.

This may only be called after start(), but it may be called safely from a separate thread.

Implemented in LogCabin::Client::LeaderRPC::Call, LogCabin::Client::anonymous_namespace{MockClientImpl.cc}::TreeLeaderRPC::Call, and LogCabin::Client::LeaderRPCMock::Call.

virtual Status LogCabin::Client::LeaderRPCBase::Call::wait ( google::protobuf::Message &  response,
TimePoint  timeout 
) [pure virtual]

Wait for the RPC to complete.

Parameters:
[out]responseIf successful, the response to the operation will be filled in here.
timeoutAfter this time has elapsed, stop waiting and return TIMEOUT. In this case, response will be left unmodified.
Returns:
True if the RPC completed successfully, false otherwise. If this returns false, it is the callers responsibility to start over to achieve the same at-most-once semantics as call().

Implemented in LogCabin::Client::LeaderRPC::Call, LogCabin::Client::anonymous_namespace{MockClientImpl.cc}::TreeLeaderRPC::Call, and LogCabin::Client::LeaderRPCMock::Call.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Status server 
) [friend]

Print out a Status for debugging purposes.

Definition at line 50 of file LeaderRPC.cc.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines