I have used protoreflect to write http-to-gRPC-gateway. But I don't see any easy option to do the reverse - gRPC-to-HTTP-gateway. One of the idea is to expose GRPC to outside but use a custom gateway to invoke internal microservices via MessageQ to avoid loadbalancing, discovery service and may be convert GRPC streaming durable or use reflection to invoke method instead of using generated server stub
Below is what I got so far
func main() {
lis, err := net.Listen("tcp", ":9091")
grpcServer := grpc.NewServer(grpc.UnknownServiceHandler(GenericHandler))
//pb.RegisterGreeterServer(grpcServer, &TestService{})
grpcServer.Serve(lis)
}
func GenericHandler(srv interface{}, stream grpc.ServerStream) error {
fullMethodName, ok := grpc.MethodFromServerStream(stream)
log.Printf("Method: %v, %v\n", fullMethodName, ok)
//how to get protobuf payload from stream
//Response:=Invoke Method via Reflection or http or MessageQueue - passing either the raw protocal buffer or as json
//how to return Response
return nil
}
The only way I see to achieve this is understand and re-implement actual handler processUnaryRPC