Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Using proto generated class in Java class vs defining individual fields separately in Java class #12163

Unanswered
jainlavina asked this question in Q&A
Discussion options

I am building a Java thick client library for a gRPC service and wondering whether tha Java request class that this library exposes to the users should inlcude the proto generated class directly vs individually define the request fields separately in the Java class.

For example given
message gRPCUserRequest {
// request fields
}

Should I define Java request class as:
class UserRequest {
gRPCUserRequest request;
}

vs

class UserRequest {
// request fields
}

Is there a downside to exposing proto generate class directly to the users in the client library?

You must be logged in to vote

Replies: 1 comment

Comment options

It's sort of up to you, but essentially it is two questions, 1) is the proto request message part of the library API and 2) is protobuf part of your API. So for (1), it's a bit of a question "does a v2 protobuf API require a v2 library API." The more your library does, the more likely you could hide major version changes of your protocol. So very thin clients often expose the messages, but the more processing you do in the library, the more you should consider hiding your dependencies. If in doubt, hiding the protobuf message types is probably the side to err on, but it really does depend on what you're doing.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /