Enhancement - protoc - service definitions - generate gRPC service definitions
johndpope opened this issue · 6 comments
I need some clarification on how to proceed with a hello world protobuffer example
There is such a library here
https://github.com/hosopy/grpc-mobile-demo-ios/blob/master/GrpcMobileDemo/HelloWorldViewController.swift
but it's not using the swift-protobuf code base.
I am using this code base - but running into some troubles.
https://github.com/johndpope/swift3-grpc-example
Namely - it appears that the service part of proto file is not generated
https://developers.google.com/protocol-buffers/docs/proto3
syntax = "proto3";
package cali.nlp;
import "syntaxnet/sentence.proto";
message ParseyRequest {
repeated string text = 1;
};
message ParseyResponse {
repeated syntaxnet.Sentence result = 1;
};
**service ParseyService** {
rpc Parse(ParseyRequest) returns (ParseyResponse);
}
According to google's webpages for third party plugins
https://github.com/google/protobuf/blob/master/docs/third_party.md
Are there any plans to support this?
after some digging found this -
https://github.com/grpc/grpc/tree/master/src/objective-c
The --objcgrpc_out plugin generates a pair of .pbrpc.h/.pbrpc.m files for each .proto file with
a service defined.
s.subspec 'Services' do |ss|
ss.source_files = "#{dir}/*.pbrpc.{h,m}"
ss.header_mappings_dir = dir
ss.requires_arc = true
# The generated files depend on the gRPC runtime, and on the files generated by --objc_out
.
ss.dependency 'gRPC-ProtoRPC'
ss.dependency "#{s.name}/Messages"
end
we need a --swiftgrpc_out
grpc is a different project that layers on top of protocol buffers. So similar to https://github.com/google/protobuf/ not directly things with services, something else is free to layer that on top of this project. Odds are https://github.com/grpc/grpc will provide one once this project is more complete.
Hey John, until we have a native gRPC Swift library, you might want to use ObjC gRPC from Swift. The automatic syntax translation makes it look pretty decent (I personally prefer to use it from Swift rather than directly in ObjC). Here's an example (to try it you just need to run pod install
in its directory and that'll generate the protos and configure the dependencies).
Thanks Jorge,
Looking forward to the day gRPC supports swift3 server side
grpc/grpc#8470
Realized I forgot to add one other thing the other day. grpc spells out one means to send the protos back and forth. But I've seen other methods used for other projects. So by keeping it out of the core protobuf project, we provide a common protobuf that can be used with all those different transport specs.
breaking news - grpc/grpc-swift#2