Protobuf: grpc: plugin flag for generate server-only or client-only

Created on 13 Jun 2017  路  6Comments  路  Source: golang/protobuf

Can some flags be added to the grpc_go plugin to allow only the required code to be generated? As done in the C# plugin.

Most helpful comment

From the C# plugin:

In a client library for other users, there's not much point in making the server API available, and it adds to pollution in the namespace.

Not only pollution, but also potentially confusing to user.

The distributed SDK can manually (or automatically) remove related server code.

That's what we are doing now. Yet, it would be nice if the server related code could be omitted with a flag in the first place.

All 6 comments

\cc @dfawley. Inside Google, I believe is a movement to provide finer granularity control over what stubs are general.

I have not heard of any such movement yet. What is the significance of this request? IIUC the only difference is that slightly fewer methods would be in the generated file, which would have a negligible effect on binary size.

Ping for @adam-26 since I forgot to at-mention earlier.

@dfawley, the issue was raised to allow for client code to be generated and distributed as part of an SDK without needing to include the server code. Nice to have, but not a blocking issue.

I'm going to go ahead and say we're unlikely to add this to the upcoming release. As @dfawley notes changes here would likely have a negligible effect on binary size or performance. It seems that as a work around, the distributed SDK that @adam-26 mentioned can manually (or automatically) remove related server code from their generated proto package for the purpose of distributing a client-only implementation. It's not clear if this is overall useful for the grpc proto plugin.

Please re-open if you think there's more utility to this than meets the eye (or at least my eyes).

From the C# plugin:

In a client library for other users, there's not much point in making the server API available, and it adds to pollution in the namespace.

Not only pollution, but also potentially confusing to user.

The distributed SDK can manually (or automatically) remove related server code.

That's what we are doing now. Yet, it would be nice if the server related code could be omitted with a flag in the first place.

Was this page helpful?
0 / 5 - 0 ratings