I don't think the HandlerRegistry approach would work in this scenario because the proxy wouldn't actually have any of those handlers registered. I've got a repo with some proof of concept code for this hypothetical gRPC-based proxy/co-process:
There are some end-to-end tests that should give a good overview of how it works:
It takes advantage of the ServerBuilder#fallbackHandlerRegistry to catch all incoming requests and forward them along to their real destination. Right now I've got it set up to do that request routing via a custom `Host` header. That approach works, but it's a little less elegant because the client has to manually add the header. The authority-based approach would save a step for the client and allow the proxy to figure out the destination via convention in the authority used on the call to the proxy.
So with that in mind, I have a couple follow-up questions:
1. Are there any glaring issues with the overall gRPC-based co-process approach? We're evaluating other options (e.g. Envoy and Linkerd), but there are some compelling arguments for building directly on gRPC. Foremost that it allows us to build all of the co-process functionality using the existing interceptor, name resolver, and load balancer infrastructure. That would make it all usable directly in fat clients/servers in scenarios where deploying a co-process is difficult.
2. Does that seem like reasonable justification for passing the authority header down to interceptors/handlers? Or maybe provide an extension point in the header decoder so that an app could include any of those pseudo headers in the header metadata, if needed? The latter seems like a good way to still allow access and avoid the slippery slope of deciding which pseudo headers are important enough to be passed along. If that approach makes sense, I could put together a PR.
Thanks!
Joey