LogCabin
|
This class is used in unit testing to interpose when clients send RPCs to the leader of the LogCabin cluster. More...
#include <LeaderRPCMock.h>
Classes | |
class | Call |
See LeaderRPCBase::Call. More... | |
Public Types | |
typedef std::unique_ptr < google::protobuf::Message > | MessagePtr |
Public Member Functions | |
LeaderRPCMock () | |
Constructor. | |
~LeaderRPCMock () | |
Destructor. | |
void | expect (OpCode opCode, const google::protobuf::Message &response) |
Expect the next request operation to have type opCode, and return it the given response. | |
MessagePtr | popRequest () |
Pop the first request from the queue. | |
Status | call (OpCode opCode, const google::protobuf::Message &request, google::protobuf::Message &response, TimePoint timeout) |
Mocks out an RPC call. | |
std::unique_ptr < LeaderRPCBase::Call > | makeCall () |
See LeaderRPCBase::makeCall. | |
Private Attributes | |
std::deque< std::pair< OpCode, MessagePtr > > | requestLog |
A queue of requests that have come in from call(). | |
std::queue< std::pair< OpCode, MessagePtr > > | responseQueue |
A queue of responses that have been primed from expect(). |
This class is used in unit testing to interpose when clients send RPCs to the leader of the LogCabin cluster.
Definition at line 35 of file LeaderRPCMock.h.
typedef std::unique_ptr<google::protobuf::Message> LogCabin::Client::LeaderRPCMock::MessagePtr |
Definition at line 37 of file LeaderRPCMock.h.
Constructor.
Definition at line 26 of file LeaderRPCMock.cc.
Destructor.
Definition at line 32 of file LeaderRPCMock.cc.
void LogCabin::Client::LeaderRPCMock::expect | ( | OpCode | opCode, |
const google::protobuf::Message & | response | ||
) |
Expect the next request operation to have type opCode, and return it the given response.
Definition at line 37 of file LeaderRPCMock.cc.
Pop the first request from the queue.
Definition at line 46 of file LeaderRPCMock.cc.
LeaderRPCMock::Status LogCabin::Client::LeaderRPCMock::call | ( | OpCode | opCode, |
const google::protobuf::Message & | request, | ||
google::protobuf::Message & | response, | ||
TimePoint | timeout | ||
) | [virtual] |
Mocks out an RPC call.
You should have called expect prior to this to prime a response. The request will be logged so you can pop it.
Implements LogCabin::Client::LeaderRPCBase.
Definition at line 54 of file LeaderRPCMock.cc.
std::unique_ptr< LeaderRPCBase::Call > LogCabin::Client::LeaderRPCMock::makeCall | ( | ) | [virtual] |
Implements LogCabin::Client::LeaderRPCBase.
Definition at line 112 of file LeaderRPCMock.cc.
std::deque<std::pair<OpCode, MessagePtr> > LogCabin::Client::LeaderRPCMock::requestLog [private] |
A queue of requests that have come in from call().
Definition at line 84 of file LeaderRPCMock.h.
std::queue<std::pair<OpCode, MessagePtr> > LogCabin::Client::LeaderRPCMock::responseQueue [private] |
A queue of responses that have been primed from expect().
Definition at line 88 of file LeaderRPCMock.h.