Add ServerReflectionInfo handler, not implemented
This commit is contained in:
@ -4,12 +4,16 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
dpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
|
dpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
rpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
|
||||||
)
|
)
|
||||||
|
|
||||||
type serverReflectionServer struct {
|
type serverReflectionServer struct {
|
||||||
@ -211,3 +215,35 @@ func (s *serverReflectionServer) allExtensionNumbersForType(st reflect.Type) ([]
|
|||||||
}
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *serverReflectionServer) ServerReflectionInfo(stream rpb.ServerReflection_ServerReflectionInfoServer) error {
|
||||||
|
for {
|
||||||
|
in, err := stream.Recv()
|
||||||
|
if err == io.EOF {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
host := in.Host
|
||||||
|
out := &rpb.ServerReflectionResponse{
|
||||||
|
ValidHost: host,
|
||||||
|
OriginalRequest: in,
|
||||||
|
}
|
||||||
|
switch in.MessageRequest.(type) {
|
||||||
|
case *rpb.ServerReflectionRequest_FileByFilename:
|
||||||
|
case *rpb.ServerReflectionRequest_FileContainingSymbol:
|
||||||
|
case *rpb.ServerReflectionRequest_FileContainingExtension:
|
||||||
|
case *rpb.ServerReflectionRequest_AllExtensionNumbersOfType:
|
||||||
|
case *rpb.ServerReflectionRequest_ListServices:
|
||||||
|
default:
|
||||||
|
return grpc.Errorf(codes.InvalidArgument, "invalid MessageRequest: %v", in.MessageRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := stream.Send(out); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user