如果我有这样的服务: service MyService { rpc GetThings(GetThingsRequest) returns (GetThingsResponse);} 我如何将GetThings标记为已弃用? 我知道如何将字段或消息标记为已弃用但我找不到有关rpcs的任何信
service MyService {
rpc GetThings(GetThingsRequest) returns (GetThingsResponse);
}
我如何将GetThings标记为已弃用?
我知道如何将字段或消息标记为已弃用但我找不到有关rpcs的任何信息.
这是针对proto3的.
TL; DR:这是可能的,但它不会生成编译器警告.考虑使用字段级别的弃用.看起来可以向服务添加一个已弃用的选项,就像在消息和枚举上一样:
service MyService {
rpc GetThings(GetThingsRequest) returns (GetThingsResponse) {
option deprecated = true;
};
}
发现于:https://github.com/google/protobuf/issues/1734
即使它确实编译,它似乎在使用时不会生成编译器警告.我在Java中尝试了0700的HelloWorld service.进一步检查生成的java文件,HelloWorldProto.java,它显示该类没有添加@Deprecated java注释,但文件中存在一些差异,很可能是原型原型描述中的注释:
$diff HelloWorldProto-{control,method}.java
38c38
< "ssage\030\001 \001(\t2I\n\007Greeter\022>\n\010SayHello\022\030.hel" +
---
> "ssage\030\001 \001(\t2L\n\007Greeter\022A\n\010SayHello\022\030.hel" +
40,41c40,41
< "eply\"\000B6\n\033io.grpc.examples.helloworldB\017H" +
< "elloWorldProtoP\001\242\002\003HLWb\006proto3"
---
> "eply\"\003\210\002\001B6\n\033io.grpc.examples.helloworld" +
> "B\017HelloWorldProtoP\001\242\002\003HLWb\006proto3"
在请求消息,服务和文件级别上尝试选项时,我得到了类似的结果.我的预感是这是java代码生成器中缺少的功能.将不推荐使用的选项添加到字段时,我确实得到了所需的编译器警告:
$./gradlew installDist ... Note: Some input files use or override a deprecated API. ...
我看到你的选择:
>将请求消息中的所有字段标记为已弃用.然后,只要有人使用它,您就会显示编译器警告.喜欢:
message HelloRequest {
string name = 1 [deprecated=true];
}
>在grpc方法上使用不使用选项(如上所示)不显示编译器警告,并依赖用户只看到此文档.>打开一个github问题.>所有以上:)
