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 @available annotations on deprecated RPCs #305

Open
eseay opened this issue Oct 2, 2024 · 2 comments
Open

Generate @available annotations on deprecated RPCs #305

eseay opened this issue Oct 2, 2024 · 2 comments
Assignees

Comments

@eseay
Copy link
Contributor

eseay commented Oct 2, 2024

Essentially a clone of connectrpc/connect-kotlin#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.

@rebello95
Copy link
Collaborator

Thanks for opening this @eseay!

Supporting the deprecated option makes a lot of sense to me, and I think it'd be a good addition to Connect-Swift.

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?

Can you comment on the upstream SwiftProtobuf issue you linked to in order to see if anything has changed on their end?

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?

I think so! We should be able to generate this at least for RPCs (and probably services, though we'd need to see if we run into a similar issue as SwiftProtobuf with the generated protocols and their class implementations). Are you interested in doing some of this exploration?

@rebello95
Copy link
Collaborator

we'd need to see if we run into a similar issue as SwiftProtobuf with the generated protocols and their class implementations)

Did a quick test, and I think we should be good on this

Screenshot 2024-10-03 at 7 59 44 PM Screenshot 2024-10-03 at 7 59 57 PM

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

No branches or pull requests

2 participants