0
votes

I have a strange situation where the message name is same as the generated class in my proto definition i.e., Service

for ex: proto file

service Dummy {
rpc Register(RegisterServiceRequest) returns Service {}
}

message Service {
    string name = 1;
}

when I generate the grpc service it becomes

pb.rb file

module ...
  module ...
    class Service

      include GRPC::GenericService

      self.marshal_class_method = :encode
      self.unmarshal_class_method = :decode
      self.service_name = 'some.Dummy'


      rpc :Register, RegisterServiceRequest, Service
  
  end

    Stub = Service.rpc_stub_class
  end
end

when I try to run it is throwing below argumenterror

/Library/Ruby/Gems/2.6.0/gems/grpc-1.23.0-universal-darwin/src/ruby/lib/grpc/generic/service.rb:126:in assert_can_marshal

/Library/Ruby/Gems/2.6.0/gems/grpc-1.23.0-universal-darwin/src/ruby/lib/grpc/generic/service.rb:94:in`rpc'

how to fix the issue? is it possible to override the name of the class Service while generating the service pb.rb file

1

1 Answers

1
votes

The clash is here:

# ⇓⇓⇓⇓⇓⇓⇓
  service Dummy {
    ...
#         ⇓⇓⇓⇓⇓⇓⇓
  message Service

There is a domestic GRPC class Service. Rename yours to use somewhat like message MessageService.