Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate a @kotlin.Deprecated annotation for deprecated RPCs #333

Closed
timostamm opened this issue Oct 1, 2024 · 0 comments · Fixed by #334
Closed

Generate a @kotlin.Deprecated annotation for deprecated RPCs #333

timostamm opened this issue Oct 1, 2024 · 0 comments · Fixed by #334

Comments

@timostamm
Copy link
Member

Protobuf has a built-in option to mark elements as deprecated. For example:

syntax="proto3";

service FooService {
  rpc Foo(FooRequest) returns (FooResponse) {
    // Is this method deprecated?
    // Depending on the target platform, this can emit Deprecated annotations
    // for the method, or it will be completely ignored; in the very least,
    // this is a formalization for deprecating methods.
    option deprecated = true;
  }
}

message FooRequest {}
message FooResponse {}

The gRPC implementation generates a kotlin.Deprecated annotation for this RPC:

    @Deprecated("The underlying service method is marked deprecated.")
    public suspend fun foo(request: FooRequest, headers: Metadata = Metadata()): FooResponse = ...

The feature was added in grpc/grpc-kotlin#264

Since it can be useful feature for team collaboration, I think we should do the same in the plugin for Connect.

For the example above, the generated client would change as follows:

public class FooServiceClient(
  private val client: ProtocolClientInterface,
) : FooServiceClientInterface {
+ @kotlin.Deprecated("The underlying service method is marked deprecated.")
  override suspend fun foo(request: FooRequest, headers: Headers): ResponseMessage<FooResponse> =

The generated client interface would change as well:

public interface FooServiceClientInterface {
+ @kotlin.Deprecated("The underlying service method is marked deprecated.")
  public suspend fun foo(request: FooRequest, headers: Headers = emptyMap()):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant