grpc - 这对 proto 文件来说是一个糟糕的结构吗
问题描述
在尝试制作具有多项服务的 gRPC 应用程序时遇到了巨大的困难,并且无法找到我的问题的原因。开始认为它可能在原型代码的结构中。
message Room {
enum Location {
Unknown = 0;
Hallway = 1;
MaleWC = 2;
FemaleWC = 3;
Office = 4;
Kitchen = 5;
ConferenceRoom = 6;
}
Location room = 1;
int32 capacity = 2;
int32 population = 3;
bool light = 4;
bool lock = 5;
}
service lightandtempcontrol {
// create a name for the rpc first -> then specify type of message to send to server
// to turn a light on upon somebody entering a room
rpc LightsOn(targetLight) returns (emptyMessage) {}; // Unary*
// to turn a light off upon someone entering the room
rpc LightsOff(targetLight) returns (lightReceipt) {};
//to regulate temperature dependent on the temperature outside
rpc OutsideTemp(stream outTemp) returns (stream indoorTemp){}; // Bidirectional*
//to get a complete
rpc Usage(usageRequest) returns (stream lightUsage) {}; // Server streaming example
}
基本上,我正在尝试创建一个可以与多个服务一起使用的 Room 类,在这些服务中获取和设置字段,但是每次我尝试基于其中一个的代码时,我都会得到不想要的结果,主要是因为我想要的值更改或比较根本不起作用。是我的原型结构中的问题。是否可以在 lightandtempcontrol 之外的其他服务中使用此 Room 消息?
解决方案
推荐阅读
- python - 在将字典的值(列表)与另一个列表进行比较时更改字典的键
- teradata - Teradata 错误 2665:日期无效
- javascript - Javascript 中声明的、未初始化的变量会发生什么?它有价值吗?
- javascript - 无法为 ASP MVC cshtml 创建重置按钮
- regex - 在记事本++中删除最后一个数字之前的字符
- sql-server - 如何验证 Azure SQL 数据库中的登录
- jquery - datepicker 在表单提交上更改日期格式
- c# - 嵌套的 UnitOfWork 在 Asp.net 应用程序中不起作用
- sonarqube - Sonar 7.x LTS 发布时间表
- python - conda 安装商业包