-
Notifications
You must be signed in to change notification settings - Fork 568
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 methods for Swift, not just structs #2502
Comments
Generating services in swift is not currently supported. I don't believe there are any short term plans to generate something; do you have something in mind of what it would look like? |
Given https://github.com/grpc/grpc/blob/master/examples/protos/helloworld.proto as sample input, without streaming, at a minimum, could just be:
Plus could add If it needs to throw an exception or two, the function signature would then be:
Plus, ideally, it would follow Swift namespacing conventions as mentioned in this proposal in the alternative repo: apple/swift-protobuf#750 (which I think was maybe met with resistance there). |
We briefly talked about it. There's no current timeline for when this might be tackled. At a minimum we would want the actual networking to be protocol oriented such that you could use (for example) Alamofire, raw URLSessions, or a custom library. @oldergod pointed out that the Kotlin generated code is built upon GrpcClient As far as naming is concerned, we would almost certainly follow existing patterns within Wire. public struct HelloRequest: ProtoMessage {
public var name: String?
}
public struct HelloReply: ProtoMessage {
public var message: String?
} As for what the
public struct Greeter: GRPCService {
public init(client: GRPCClient) { ... }
func SayHello(request: HelloRequest) async throws -> HelloReply { ... }
}
protocol Greeter {
func SayHello(request: HelloRequest) async throws -> HelloReply
}
extension Greeter where Self: GRPCClient {
public func SayHello(request: HelloRequest) async throws -> HelloReply { ... }
} 2 has the benefit of letting you mock |
Consider the following "hello world" proto:
https://github.com/grpc/grpc/blob/master/examples/protos/helloworld.proto
Compare the following commands:
java -jar wire-compiler-4.7.2-jar-with-dependencies.jar --proto_path=. --kotlin_out=. helloworld.proto
java -jar wire-compiler-4.7.2-jar-with-dependencies.jar --proto_path=. --swift_out=. helloworld.proto
Running the Kotlin version (1 above) generates the following four files:
Running the Swift version (2 above), however, generates only:
How to generate the two missing files for Swift also? (For example, a Swift protocol and a class or struct that conforms to that protocol, which contains Swift methods?) Otherwise all we have is models (structs). If it's not currently possible to generate Swift methods, what is the use case for the Swift Wire version in its current form?
The text was updated successfully, but these errors were encountered: