Closed Choongkyu closed 4 years ago
Hey @zebralight, we do have gRPC examples that already exist here:
It's hard to tell what's happening without the full context of the generated code, but it seems like your Server
does not implement the generated YARPC interface.
getValue
which should be public: GetValue
SetValue
, the second method defined in your Protobuf filePlease check out the examples and re-open if you have any questions!
hi @AlexAPB. thank you for the response. I made the advised change of setting getValue
to be public but am seeing the same error issued which was:
server/main.go:89:62: cannot use server (type *Server) as type keyvalue.KeyValueYARPCServer in argument to keyvalue.BuildKeyValueYARPCProcedures:
*Server does not implement keyvalue.KeyValueYARPCServer (missing keyvalue.getValue method)
have GetValue(context.Context, *keyvalue.GetValueRequest) (*keyvalue.GetValueResponse, error)
want keyvalue.getValue(context.Context, *keyvalue.GetValueRequest) (*keyvalue.GetValueResponse, error)
. I've also added SetValue
and didn't include it in the original ticket since the error was only alerting me about getValue
.
I just tried out the protobuf example and tried running it and then calling it with this yab:
service: example
method: EchoIn
peer: grpc://127.0.0.1:34111
timeout: 1000ms
request:
message: "foo"
num_responses: 3
and am getting this response:
Failed while parsing input: rpc error: code = Unimplemented desc = unrecognized procedure "grpc.reflection.v1alpha.ServerReflection::ServerReflectionInfo" for service "example"
thanks again!
Ah, so you've actually run into two interesting edge cases.
The first issue is that your Protobuf file is defining methods using camelCase instead of PascalCase (ie setFoo
instead of SetFoo
). This is causing YARPC's protoc
plugin to generate private methods on the interface, which are unimplementable if generated into a separate package. At Uber, we don't run into this issue since we have linters than enforce methods to be PascalCase.
Next, internally some services use an Fx layer that enables the gRPC reflection protocol. Since you are not hooking up the reflection server manually, you'll need to use protoc
and pass the FileDescriptorSet
using -F
(I do not recall if this works with yab-YAML files)
$ yab --help
...
-F, --file-descriptor-set-bin= A binary file containing a compiled protobuf FileDescriptorSet.
thank you very much! Swapping to pascal case and adding that flag fixed both issues.
Hello. I am trying to get the keyvalue-thrift example working with grpc and after having compiled a proto file, I'm unable to run it and get the following error:
The altered version of thrift-keyvalue is as follows:
and the proto file: