convention related to creating v2 endpoints for grpc services ?

28 views
Skip to first unread message

Sahil Kharb

unread,
Apr 18, 2017, 2:51:21 PM4/18/17
to grpc.io
Hello all,

What kind of approach is suggested if we are creating v2 version for existing methods ?

So, whenever we create the v2 endpoints, the chances of code duplication is very high, has anyone come up with any clean approach ??

Open for all kinds of suggestion.

Eric Anderson

unread,
Apr 18, 2017, 6:57:35 PM4/18/17
to Sahil Kharb, grpc.io
To begin, have the API version in the protobuf package name. That allows you to have the new and old APIs in the same binary. If you can then implement the v1 API using the v2 API it reduces the maintenance burden. If the two APIs are different enough that you can't implement v1 in v2, then yes, you'll have a harder time avoiding duplication.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/2ccedc2c-af17-4100-83f4-02e7de40a2ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sahil Kharb

unread,
Apr 19, 2017, 1:00:27 AM4/19/17
to grpc.io
How about using implementing service interceptors which will act as middlewares and these middlewares will perform the additional work and then forward the message to v1 method.
Any concerns around this?

Eric Anderson

unread,
Apr 24, 2017, 11:39:16 AM4/24/17
to Sahil Kharb, grpc.io
I'd generally recommend against trying to do that, simply because it would only work in a very limited set of situations. Also, using a middleware doesn't actually gain you anything since the logic is probably method-specific. Middleware is good for cross-cutting features that are mostly independent of method being called. Converting between API versions is rarely generic.

It'd also have trouble with the (static) types used with the generated code.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
Reply all
Reply to author
Forward
0 new messages