我有一个简单的客户端和服务器设置。客户端想要使用ZeroMQ进行通信,执行服务器中的一个方法。我将使用REQ和REP套接字,因为它们适用于此用例。但是,我对protobuf定义有疑问。我认为以下两个选项可用于实现目标:
message ControlService{
string control = 1;
int32 serverId = 2;
bool block = 3;
double temperature = 4;
}
"control"参数包含需要远程执行的方法名称。另一种可选方案是:
message InputParameters{
int32 serverId = 1;
bool block = 2;
double temperature = 3;
}
message Empty{
}
service ControlService{
rpc control (InputParameters) returns (Empty);
}
什么是最好的方法?或者至少使用一种方法的代价是什么,相比之下又有哪些优劣呢?