How to mark rpc as deprecated

If I have such a service:

service MyService {
  rpc GetThings(GetThingsRequest) returns (GetThingsResponse);
}

How can I mark GetThingsas deprecated?

I know how to mark fields or messages as outdated, but I cannot find any information about rpcs.

This is for proto3.

+4
source share
1 answer

TL DR: Maybe, but it does not generate a compiler warning. Consider using field level deviation.

It seems that you can add an obsolete option to the service, as in the message and listing like:

service MyService {
  rpc GetThings(GetThingsRequest) returns (GetThingsResponse) {
    option deprecated = true;
  };
}

This is discovered at: https://github.com/google/protobuf/issues/1734

, , , , . Java, HelloWorld Java . 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.
  • :)
+3

Source: https://habr.com/ru/post/1674294/


All Articles