LogCabin
|
This class represents the server side of a remote procedure call. More...
#include <ServerRPC.h>
Public Member Functions | |
ServerRPC () | |
Default constructor for empty RPC that can't be replied to. | |
ServerRPC (ServerRPC &&other) | |
Move constructor. | |
~ServerRPC () | |
Destructor. | |
ServerRPC & | operator= (ServerRPC &&other) |
Move assignment. | |
bool | needsReply () const |
Returns whether this RPC is waiting for a reply. | |
uint16_t | getService () const |
This identifies which Service the RPC is destined for. | |
uint8_t | getServiceSpecificErrorVersion () const |
This tells the Service what service-specific errors the client understands. | |
uint16_t | getOpCode () const |
Return which RPC is being executed, scoped to the service. | |
bool | getRequest (google::protobuf::Message &request) |
Parse the request out of the RPC. | |
bool | getRequest (Core::Buffer &buffer) const |
Copy the request out of the RPC. | |
void | reply (const google::protobuf::Message &payload) |
Send a normal response back to the client. | |
void | returnError (const google::protobuf::Message &serviceSpecificError) |
Send a service-specific error back to the client. | |
void | rejectInvalidService () |
Reject the RPC on the grounds that it specifies an invalid service ID. | |
void | rejectInvalidRequest () |
Reject the RPC on the grounds that it specifies an invalid request. | |
void | closeSession () |
Close the session on which this request originated. | |
Private Member Functions | |
ServerRPC (OpaqueServerRPC opaqueRPC) | |
Constructor for ServerRPC. | |
void | reject (RPC::Protocol::Status status) |
Reject the RPC. | |
ServerRPC (const ServerRPC &) | |
ServerRPC & | operator= (const ServerRPC &) |
Private Attributes | |
OpaqueServerRPC | opaqueRPC |
The underlying transport-level RPC object. | |
bool | active |
Set to true if the RPC needs a reply, false otherwise. | |
uint16_t | service |
See getService(). | |
uint8_t | serviceSpecificErrorVersion |
See getServiceSpecificErrorVersion(). | |
uint16_t | opCode |
See getOpCode(). | |
Friends | |
class | Server |
This class represents the server side of a remote procedure call.
A Server creates an instance when an RPC is initiated. This is used to send the reply.
This class may be used from any thread, but each object is meant to be accessed by only one thread at a time.
Definition at line 37 of file ServerRPC.h.
LogCabin::RPC::ServerRPC::ServerRPC | ( | OpaqueServerRPC | opaqueRPC | ) | [explicit, private] |
Constructor for ServerRPC.
This is called by Server only.
Definition at line 29 of file ServerRPC.cc.
Default constructor for empty RPC that can't be replied to.
This is useful as a placeholder for a real ServerRPC.
Definition at line 60 of file ServerRPC.cc.
LogCabin::RPC::ServerRPC::ServerRPC | ( | ServerRPC && | other | ) |
Move constructor.
Definition at line 69 of file ServerRPC.cc.
Destructor.
Definition at line 79 of file ServerRPC.cc.
LogCabin::RPC::ServerRPC::ServerRPC | ( | const ServerRPC & | ) | [private] |
Move assignment.
Definition at line 89 of file ServerRPC.cc.
bool LogCabin::RPC::ServerRPC::needsReply | ( | ) | const [inline] |
uint16_t LogCabin::RPC::ServerRPC::getService | ( | ) | const [inline] |
uint8_t LogCabin::RPC::ServerRPC::getServiceSpecificErrorVersion | ( | ) | const [inline] |
This tells the Service what service-specific errors the client understands.
Services should take care not to send a client a service-specific error that it doesn't understand.
Definition at line 91 of file ServerRPC.h.
uint16_t LogCabin::RPC::ServerRPC::getOpCode | ( | ) | const [inline] |
Return which RPC is being executed, scoped to the service.
Definition at line 98 of file ServerRPC.h.
bool LogCabin::RPC::ServerRPC::getRequest | ( | google::protobuf::Message & | request | ) |
Parse the request out of the RPC.
[out] | request | An empty protocol buffer the request will be be unpacked into. |
Definition at line 101 of file ServerRPC.cc.
bool LogCabin::RPC::ServerRPC::getRequest | ( | Core::Buffer & | buffer | ) | const |
Copy the request out of the RPC.
[out] | buffer | An empty buffer that the request will be copied into. |
Definition at line 114 of file ServerRPC.cc.
void LogCabin::RPC::ServerRPC::reply | ( | const google::protobuf::Message & | payload | ) |
Send a normal response back to the client.
payload | A protocol buffer to serialize into the response. |
Definition at line 132 of file ServerRPC.cc.
void LogCabin::RPC::ServerRPC::returnError | ( | const google::protobuf::Message & | serviceSpecificError | ) |
Send a service-specific error back to the client.
serviceSpecificError | Details explaining the error to send back to the client. |
Definition at line 148 of file ServerRPC.cc.
Reject the RPC on the grounds that it specifies an invalid service ID.
Definition at line 164 of file ServerRPC.cc.
Reject the RPC on the grounds that it specifies an invalid request.
Definition at line 170 of file ServerRPC.cc.
Close the session on which this request originated.
This is an impolite thing to do to a client but can be useful occasionally, for example for testing.
Definition at line 176 of file ServerRPC.cc.
void LogCabin::RPC::ServerRPC::reject | ( | RPC::Protocol::Status | status | ) | [private] |
Reject the RPC.
status | This should be INVALID_VERSION, INVALID_SERVICE, or INVALID_REQUEST. |
Definition at line 183 of file ServerRPC.cc.
friend class Server [friend] |
Definition at line 182 of file ServerRPC.h.
The underlying transport-level RPC object.
It doesn't know how to interpret the raw bytes of the RPC, but it gets them from here to there.
Definition at line 168 of file ServerRPC.h.
bool LogCabin::RPC::ServerRPC::active [private] |
Set to true if the RPC needs a reply, false otherwise.
Definition at line 173 of file ServerRPC.h.
uint16_t LogCabin::RPC::ServerRPC::service [private] |
See getService().
Definition at line 176 of file ServerRPC.h.
uint8_t LogCabin::RPC::ServerRPC::serviceSpecificErrorVersion [private] |
See getServiceSpecificErrorVersion().
Definition at line 178 of file ServerRPC.h.
uint16_t LogCabin::RPC::ServerRPC::opCode [private] |
See getOpCode().
Definition at line 180 of file ServerRPC.h.