connect-swift icon indicating copy to clipboard operation
connect-swift copied to clipboard

Generate @available annotations on deprecated RPCs

Open eseay opened this issue 1 year ago • 2 comments

Essentially a clone of https://github.com/connectrpc/connect-kotlin/issues/333, but for Swift. Examples below largely influenced by that issue in connect-kotlin.

This would be a very helpful enhancement to the library, as it would allow more effective passive communication from services to their dependents about when certain existing functionality is being deprecated.

There is an ongoing discussion in the apple/swift-protobuf library here about adding this functionality to swift-protobuf itself. Given the age of that discussion, I'd like to consider:

  • Is this something that the Connect community would like to try to revitalize?
  • Do the challenges that prevented the feature from being implemented some years ago still exist?
  • Is there merit in adding this functionality to the connect-swift plugin for its generated services in the absence of it being implemented for models and properties in swift-protobuf?
syntax="proto3";

service FooService {
  rpc Foo(FooRequest) returns (FooResponse) {
    // Formally marks the service as being deprecated.
    option deprecated = true;
  }
}

message FooRequest {}
message FooResponse {}

Would generate output like:

public protocol FooServiceClientInterface: Sendable {

-    @available(iOS 13, *)
+    @available(iOS, introduced: 13, deprecated: 13)
    func `foo`(request: FooRequest, headers: Connect.Headers) async -> ResponseMessage<FooResponse>
}

There are obviously a few more details to this that we have to consider for other function types, as this only demonstrates a proposed change for the async functions, but all adjustments would be fundamentally similar in nature.

eseay avatar Oct 02 '24 18:10 eseay