The style guide you linked to is the main resource I know of for
recommendations on writing .proto files.

About your point 1), you must use a single message type for the
request--using multiple arguments or non-message types is not supported. So
fortunately, your "good" example is the required way of doing things.

About message segregation, I don't think there's a hard rule but it's more
of a judgment call. I would tend to break up .proto files based on the
dependencies between the messages and how they relate to each other. If you
have a bunch of small messages that are all logically related and have some
dependencies between them, I would put them in the same file. But if the
message definitions start to grow large or become less closely related, I
would start thinking about breaking them up into separate files.

If your .proto files start to become really huge and you're using C++, you
might eventually need to start worrying about compile times getting too
long, and at that point you would probably want to start reorganizing your
.proto files to minimize the amount of extra work the compiler has to do.
But unless you're working on a particularly large codebase, that's not
likely to become much of an issue.

On Thu, Jan 26, 2017 at 5:57 AM, Igor Dmitriev <ihor.dmitri...@gmail.com>
wrote:

> Hi guys, I've just started to work with Protobuf and I am wondering how to
> write good .proto files.
> Are there any best practices, guides, conventions or smth similar??
> I got an idea about services:
> 1. UserService {
>    rpc CreateUser(CreateUserRequest) return (CreateUserResponse)  - good
>    rpc CreateUser(string first_name, string last_name, int32 age) return
> (ClientResponse)  - ugly
> }
>
> 2. But what do you think about messages segregation ?
> I think it's good strategy of putting all the messages in separate files
> instead of a single file.
> In this case it's easier to maintain and reuse messages, but there are a
> lot of examples on the internet and on official protocol-buffers
> website where all messages are placed in one file.
>
> My founds:
> https://developers.google.com/protocol-buffers/docs/proto3
> https://developers.google.com/protocol-buffers/docs/style
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to