service UserServiceRpc //在test.proto中定义
{
rpc Login(LoginRequest)returns(LoginResponse);
rpc GetFriendLists(GetFriendListRequest)returns(GetFriendListResponse);
}
test.proto文件生成test.pb.cc protoc test.proto --cpp_out=./ 将生成的文件放到 ./ 目录下,截取一部分如下
class UserServiceRpc_Stub;
class UserServiceRpc : public ::PROTOBUF_NAMESPACE_ID::Service {
protected:
// This class should be treated as an abstract interface.
inline UserServiceRpc() {};
public:
virtual ~UserServiceRpc();
typedef UserServiceRpc_Stub Stub;
static const ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor* descriptor();
virtual void Login(::PROTOBUF_NAMESPACE_ID::RpcController* controller,
const ::fixbug::LoginRequest* request,
::fixbug::LoginResponse* response,
::google::protobuf::Closure* done);
virtual void GetFriendLists(::PROTOBUF_NAMESPACE_ID::RpcController* controller,
const ::fixbug::GetFriendListRequest* request,
::fixbug::GetFriendListResponse* response,
::google::protobuf::Closure* done);
调用关系如图所示:
在test.proto中的LoginRequest类继承于protobuf的Message类,UserServiceRpc继承于protobuf的service类中。service类中包含两个虚函数即在UserServiceRpc中的两个方法,UserServiceRpc_Stub继承UserServiceRpc,此类多了RpcChannel指针,方法将会通过Rpcchannel指针调用CallMethod函数,我们将用自己写的类继承Rpcchannel,重写其中的CallMethod方法,将派生类对象传给基类指针从而调用派生类里的函数。




![[Spring Cloud] (4)搭建Vue2与网关、微服务通信并配置跨域](https://img-blog.csdnimg.cn/img_convert/0089662f313198fb47a2fa99884e6678.png)









![【Hadoop】- MapReduce YARN的部署[8]](https://img-blog.csdnimg.cn/direct/2db7663582ac4a1fa825037da60fc7d6.png)

![【Hadoop】- MapReduce YARN 初体验[9]](https://img-blog.csdnimg.cn/direct/f09935e8bade4d16a28d0d5ce9f9e616.png)


