【发布时间】:2017-12-30 22:43:35
【问题描述】:
我有一个客户端和一个服务器的简单设置。客户端希望使用 ZeroMQ 在服务器中执行一个方法进行通信。我将使用 REQ 和 REP 套接字,因为它们适用于这个用例。不过,我对 protobuf 的定义有疑问。我认为这两个选项可以用来实现目标:
message ControlService{
string control = 1;
int32 serverId = 2;
bool block = 3;
double temperature = 4;
}
其中“控制”包含要远程执行的方法的名称。另一种选择是:
message InputParameters{
int32 serverId = 1;
bool block = 2;
double temperature = 3;
}
message Empty{
}
service ControlService{
rpc control (InputParameters) returns (Empty);
}
最好的方法是什么?或者至少使用一种方法而不是另一种方法的权衡是什么?
【问题讨论】: