Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the use of a server as a client #1263

Closed
tomwilkie opened this issue May 29, 2017 · 3 comments
Closed

Allow the use of a server as a client #1263

tomwilkie opened this issue May 29, 2017 · 3 comments
Labels
P3 Status: Won't Fix Type: Feature New features or improvements in behavior

Comments

@tomwilkie
Copy link
Contributor

Sometimes (for instance, when testing) it is useful to skip the whole RPC layer and just wire up the system in a single process. As such, I would like to be able to use my gRPC server types as clients but I can't, as the client wants to pass the extra grcp.CallOptions.

Would you consider auto-generating an adapter type to allow people to do this? It would be a little more complicated to support the various streaming interfaces too, but nothing to difficult. An example of a manually written adapter is here: https://github.com/weaveworks/cortex/blob/master/pkg/ingester/ingester_lifecycle_test.go#L248

@dfawley
Copy link
Member

dfawley commented Aug 31, 2017

Upon further consideration, I don't think this is a good idea. The "extra" CallOptions can do things like specify metadata, which may affect the behavior of the server.

I believe what you really want is #906 to cut out unnecessary gRPC processing while still doing the things it needs to do that affect client/server interaction.

@dfawley dfawley closed this as completed Aug 31, 2017
@mackross
Copy link

We're not that concerned with serialization overhead but during development having all services in one binary and stack traces through RPC would be great.

@dfawley
Copy link
Member

dfawley commented Sep 13, 2017

You don't need this feature to do that. You can put your clients and services in one binary and have the server serve to a free port on localhost, with the clients dialing that same port.

Or, you could try out our bufconn package that we use for some of our testing to avoid the network stack entirely. To use it, you pass a bufconn.Listener to a grpc.Server's Serve method, and pass the listener's Dial function as a custom dialer via the WithDialer call option. (Wrap it to ignore the args.)

@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 Status: Won't Fix Type: Feature New features or improvements in behavior
Projects
None yet
Development

No branches or pull requests

3 participants