Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protobuf import failure

Does anyone know where I can find an example of a gRPC protobuf file that imports from a different file and uses a protobuf message in a return? I can't find any at all.

I have a file...

syntax = "proto3";
package a1;
import "a.proto";
service mainservice {
  rpc DoSomething(...) returns (a.SomeResponse) {}


}

a.proto is also in the same directory and also compiles by itself. The error messages I'm getting are: "a.SomeResponse" is not defined. mainfile.proto: warning: Import a.proto but not used.

like image 765
user3125693 Avatar asked Dec 14 '16 19:12

user3125693


People also ask

How do I import Protos?

To import another .proto 's definitions, you add an import statement to the top of your file: import "myproject/other_protos.proto"; By default, you can use definitions only from directly imported .proto files. However, sometimes you may need to move a .proto file to a new location.

What is Protobuf Python?

Protocol buffers (Protobuf) are a language-agnostic data serialization format developed by Google. Protobuf is great for the following reasons: Low data volume: Protobuf makes use of a binary format, which is more compact than other formats such as JSON. Persistence: Protobuf serialization is backward-compatible.

What is Protobuf package?

The . proto file starts with a package declaration, which helps to prevent naming conflicts between different projects.

What is -- Proto_path?

-I and --proto_path are the same flag: -I is the shorthand version. The purpose of the flag is to specify a directory in which to look for imported files, much like the C compiler's -I flag, Java's CLASSPATH environment variable, Python's PYTHONPATH , etc.


1 Answers

Found the answer... need to make sure the package name of a.proto is used when specifying the object imported (eg a_package_name.SomeResponse)

like image 191
user3125693 Avatar answered Oct 26 '22 17:10

user3125693