vendor files

This commit is contained in:
Serguei Bezverkhi
2018-01-09 13:57:14 -05:00
parent 558bc6c02a
commit 7b24313bd6
16547 changed files with 4527373 additions and 0 deletions

18
vendor/google.golang.org/grpc/reflection/README.md generated vendored Normal file
View File

@ -0,0 +1,18 @@
# Reflection
Package reflection implements server reflection service.
The service implemented is defined in: https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto.
To register server reflection on a gRPC server:
```go
import "google.golang.org/grpc/reflection"
s := grpc.NewServer()
pb.RegisterYourOwnServer(s, &server{})
// Register reflection service on gRPC server.
reflection.Register(s)
s.Serve(lis)
```

View File

@ -0,0 +1,763 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: grpc_reflection_v1alpha/reflection.proto
/*
Package grpc_reflection_v1alpha is a generated protocol buffer package.
It is generated from these files:
grpc_reflection_v1alpha/reflection.proto
It has these top-level messages:
ServerReflectionRequest
ExtensionRequest
ServerReflectionResponse
FileDescriptorResponse
ExtensionNumberResponse
ListServiceResponse
ServiceResponse
ErrorResponse
*/
package grpc_reflection_v1alpha
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import (
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
// The message sent by the client when calling ServerReflectionInfo method.
type ServerReflectionRequest struct {
Host string `protobuf:"bytes,1,opt,name=host" json:"host,omitempty"`
// To use reflection service, the client should set one of the following
// fields in message_request. The server distinguishes requests by their
// defined field and then handles them using corresponding methods.
//
// Types that are valid to be assigned to MessageRequest:
// *ServerReflectionRequest_FileByFilename
// *ServerReflectionRequest_FileContainingSymbol
// *ServerReflectionRequest_FileContainingExtension
// *ServerReflectionRequest_AllExtensionNumbersOfType
// *ServerReflectionRequest_ListServices
MessageRequest isServerReflectionRequest_MessageRequest `protobuf_oneof:"message_request"`
}
func (m *ServerReflectionRequest) Reset() { *m = ServerReflectionRequest{} }
func (m *ServerReflectionRequest) String() string { return proto.CompactTextString(m) }
func (*ServerReflectionRequest) ProtoMessage() {}
func (*ServerReflectionRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
type isServerReflectionRequest_MessageRequest interface {
isServerReflectionRequest_MessageRequest()
}
type ServerReflectionRequest_FileByFilename struct {
FileByFilename string `protobuf:"bytes,3,opt,name=file_by_filename,json=fileByFilename,oneof"`
}
type ServerReflectionRequest_FileContainingSymbol struct {
FileContainingSymbol string `protobuf:"bytes,4,opt,name=file_containing_symbol,json=fileContainingSymbol,oneof"`
}
type ServerReflectionRequest_FileContainingExtension struct {
FileContainingExtension *ExtensionRequest `protobuf:"bytes,5,opt,name=file_containing_extension,json=fileContainingExtension,oneof"`
}
type ServerReflectionRequest_AllExtensionNumbersOfType struct {
AllExtensionNumbersOfType string `protobuf:"bytes,6,opt,name=all_extension_numbers_of_type,json=allExtensionNumbersOfType,oneof"`
}
type ServerReflectionRequest_ListServices struct {
ListServices string `protobuf:"bytes,7,opt,name=list_services,json=listServices,oneof"`
}
func (*ServerReflectionRequest_FileByFilename) isServerReflectionRequest_MessageRequest() {}
func (*ServerReflectionRequest_FileContainingSymbol) isServerReflectionRequest_MessageRequest() {}
func (*ServerReflectionRequest_FileContainingExtension) isServerReflectionRequest_MessageRequest() {}
func (*ServerReflectionRequest_AllExtensionNumbersOfType) isServerReflectionRequest_MessageRequest() {}
func (*ServerReflectionRequest_ListServices) isServerReflectionRequest_MessageRequest() {}
func (m *ServerReflectionRequest) GetMessageRequest() isServerReflectionRequest_MessageRequest {
if m != nil {
return m.MessageRequest
}
return nil
}
func (m *ServerReflectionRequest) GetHost() string {
if m != nil {
return m.Host
}
return ""
}
func (m *ServerReflectionRequest) GetFileByFilename() string {
if x, ok := m.GetMessageRequest().(*ServerReflectionRequest_FileByFilename); ok {
return x.FileByFilename
}
return ""
}
func (m *ServerReflectionRequest) GetFileContainingSymbol() string {
if x, ok := m.GetMessageRequest().(*ServerReflectionRequest_FileContainingSymbol); ok {
return x.FileContainingSymbol
}
return ""
}
func (m *ServerReflectionRequest) GetFileContainingExtension() *ExtensionRequest {
if x, ok := m.GetMessageRequest().(*ServerReflectionRequest_FileContainingExtension); ok {
return x.FileContainingExtension
}
return nil
}
func (m *ServerReflectionRequest) GetAllExtensionNumbersOfType() string {
if x, ok := m.GetMessageRequest().(*ServerReflectionRequest_AllExtensionNumbersOfType); ok {
return x.AllExtensionNumbersOfType
}
return ""
}
func (m *ServerReflectionRequest) GetListServices() string {
if x, ok := m.GetMessageRequest().(*ServerReflectionRequest_ListServices); ok {
return x.ListServices
}
return ""
}
// XXX_OneofFuncs is for the internal use of the proto package.
func (*ServerReflectionRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
return _ServerReflectionRequest_OneofMarshaler, _ServerReflectionRequest_OneofUnmarshaler, _ServerReflectionRequest_OneofSizer, []interface{}{
(*ServerReflectionRequest_FileByFilename)(nil),
(*ServerReflectionRequest_FileContainingSymbol)(nil),
(*ServerReflectionRequest_FileContainingExtension)(nil),
(*ServerReflectionRequest_AllExtensionNumbersOfType)(nil),
(*ServerReflectionRequest_ListServices)(nil),
}
}
func _ServerReflectionRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
m := msg.(*ServerReflectionRequest)
// message_request
switch x := m.MessageRequest.(type) {
case *ServerReflectionRequest_FileByFilename:
b.EncodeVarint(3<<3 | proto.WireBytes)
b.EncodeStringBytes(x.FileByFilename)
case *ServerReflectionRequest_FileContainingSymbol:
b.EncodeVarint(4<<3 | proto.WireBytes)
b.EncodeStringBytes(x.FileContainingSymbol)
case *ServerReflectionRequest_FileContainingExtension:
b.EncodeVarint(5<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.FileContainingExtension); err != nil {
return err
}
case *ServerReflectionRequest_AllExtensionNumbersOfType:
b.EncodeVarint(6<<3 | proto.WireBytes)
b.EncodeStringBytes(x.AllExtensionNumbersOfType)
case *ServerReflectionRequest_ListServices:
b.EncodeVarint(7<<3 | proto.WireBytes)
b.EncodeStringBytes(x.ListServices)
case nil:
default:
return fmt.Errorf("ServerReflectionRequest.MessageRequest has unexpected type %T", x)
}
return nil
}
func _ServerReflectionRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*ServerReflectionRequest)
switch tag {
case 3: // message_request.file_by_filename
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.MessageRequest = &ServerReflectionRequest_FileByFilename{x}
return true, err
case 4: // message_request.file_containing_symbol
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.MessageRequest = &ServerReflectionRequest_FileContainingSymbol{x}
return true, err
case 5: // message_request.file_containing_extension
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(ExtensionRequest)
err := b.DecodeMessage(msg)
m.MessageRequest = &ServerReflectionRequest_FileContainingExtension{msg}
return true, err
case 6: // message_request.all_extension_numbers_of_type
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.MessageRequest = &ServerReflectionRequest_AllExtensionNumbersOfType{x}
return true, err
case 7: // message_request.list_services
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.MessageRequest = &ServerReflectionRequest_ListServices{x}
return true, err
default:
return false, nil
}
}
func _ServerReflectionRequest_OneofSizer(msg proto.Message) (n int) {
m := msg.(*ServerReflectionRequest)
// message_request
switch x := m.MessageRequest.(type) {
case *ServerReflectionRequest_FileByFilename:
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.FileByFilename)))
n += len(x.FileByFilename)
case *ServerReflectionRequest_FileContainingSymbol:
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.FileContainingSymbol)))
n += len(x.FileContainingSymbol)
case *ServerReflectionRequest_FileContainingExtension:
s := proto.Size(x.FileContainingExtension)
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *ServerReflectionRequest_AllExtensionNumbersOfType:
n += proto.SizeVarint(6<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.AllExtensionNumbersOfType)))
n += len(x.AllExtensionNumbersOfType)
case *ServerReflectionRequest_ListServices:
n += proto.SizeVarint(7<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.ListServices)))
n += len(x.ListServices)
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
// The type name and extension number sent by the client when requesting
// file_containing_extension.
type ExtensionRequest struct {
// Fully-qualified type name. The format should be <package>.<type>
ContainingType string `protobuf:"bytes,1,opt,name=containing_type,json=containingType" json:"containing_type,omitempty"`
ExtensionNumber int32 `protobuf:"varint,2,opt,name=extension_number,json=extensionNumber" json:"extension_number,omitempty"`
}
func (m *ExtensionRequest) Reset() { *m = ExtensionRequest{} }
func (m *ExtensionRequest) String() string { return proto.CompactTextString(m) }
func (*ExtensionRequest) ProtoMessage() {}
func (*ExtensionRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *ExtensionRequest) GetContainingType() string {
if m != nil {
return m.ContainingType
}
return ""
}
func (m *ExtensionRequest) GetExtensionNumber() int32 {
if m != nil {
return m.ExtensionNumber
}
return 0
}
// The message sent by the server to answer ServerReflectionInfo method.
type ServerReflectionResponse struct {
ValidHost string `protobuf:"bytes,1,opt,name=valid_host,json=validHost" json:"valid_host,omitempty"`
OriginalRequest *ServerReflectionRequest `protobuf:"bytes,2,opt,name=original_request,json=originalRequest" json:"original_request,omitempty"`
// The server set one of the following fields according to the message_request
// in the request.
//
// Types that are valid to be assigned to MessageResponse:
// *ServerReflectionResponse_FileDescriptorResponse
// *ServerReflectionResponse_AllExtensionNumbersResponse
// *ServerReflectionResponse_ListServicesResponse
// *ServerReflectionResponse_ErrorResponse
MessageResponse isServerReflectionResponse_MessageResponse `protobuf_oneof:"message_response"`
}
func (m *ServerReflectionResponse) Reset() { *m = ServerReflectionResponse{} }
func (m *ServerReflectionResponse) String() string { return proto.CompactTextString(m) }
func (*ServerReflectionResponse) ProtoMessage() {}
func (*ServerReflectionResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
type isServerReflectionResponse_MessageResponse interface {
isServerReflectionResponse_MessageResponse()
}
type ServerReflectionResponse_FileDescriptorResponse struct {
FileDescriptorResponse *FileDescriptorResponse `protobuf:"bytes,4,opt,name=file_descriptor_response,json=fileDescriptorResponse,oneof"`
}
type ServerReflectionResponse_AllExtensionNumbersResponse struct {
AllExtensionNumbersResponse *ExtensionNumberResponse `protobuf:"bytes,5,opt,name=all_extension_numbers_response,json=allExtensionNumbersResponse,oneof"`
}
type ServerReflectionResponse_ListServicesResponse struct {
ListServicesResponse *ListServiceResponse `protobuf:"bytes,6,opt,name=list_services_response,json=listServicesResponse,oneof"`
}
type ServerReflectionResponse_ErrorResponse struct {
ErrorResponse *ErrorResponse `protobuf:"bytes,7,opt,name=error_response,json=errorResponse,oneof"`
}
func (*ServerReflectionResponse_FileDescriptorResponse) isServerReflectionResponse_MessageResponse() {}
func (*ServerReflectionResponse_AllExtensionNumbersResponse) isServerReflectionResponse_MessageResponse() {
}
func (*ServerReflectionResponse_ListServicesResponse) isServerReflectionResponse_MessageResponse() {}
func (*ServerReflectionResponse_ErrorResponse) isServerReflectionResponse_MessageResponse() {}
func (m *ServerReflectionResponse) GetMessageResponse() isServerReflectionResponse_MessageResponse {
if m != nil {
return m.MessageResponse
}
return nil
}
func (m *ServerReflectionResponse) GetValidHost() string {
if m != nil {
return m.ValidHost
}
return ""
}
func (m *ServerReflectionResponse) GetOriginalRequest() *ServerReflectionRequest {
if m != nil {
return m.OriginalRequest
}
return nil
}
func (m *ServerReflectionResponse) GetFileDescriptorResponse() *FileDescriptorResponse {
if x, ok := m.GetMessageResponse().(*ServerReflectionResponse_FileDescriptorResponse); ok {
return x.FileDescriptorResponse
}
return nil
}
func (m *ServerReflectionResponse) GetAllExtensionNumbersResponse() *ExtensionNumberResponse {
if x, ok := m.GetMessageResponse().(*ServerReflectionResponse_AllExtensionNumbersResponse); ok {
return x.AllExtensionNumbersResponse
}
return nil
}
func (m *ServerReflectionResponse) GetListServicesResponse() *ListServiceResponse {
if x, ok := m.GetMessageResponse().(*ServerReflectionResponse_ListServicesResponse); ok {
return x.ListServicesResponse
}
return nil
}
func (m *ServerReflectionResponse) GetErrorResponse() *ErrorResponse {
if x, ok := m.GetMessageResponse().(*ServerReflectionResponse_ErrorResponse); ok {
return x.ErrorResponse
}
return nil
}
// XXX_OneofFuncs is for the internal use of the proto package.
func (*ServerReflectionResponse) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
return _ServerReflectionResponse_OneofMarshaler, _ServerReflectionResponse_OneofUnmarshaler, _ServerReflectionResponse_OneofSizer, []interface{}{
(*ServerReflectionResponse_FileDescriptorResponse)(nil),
(*ServerReflectionResponse_AllExtensionNumbersResponse)(nil),
(*ServerReflectionResponse_ListServicesResponse)(nil),
(*ServerReflectionResponse_ErrorResponse)(nil),
}
}
func _ServerReflectionResponse_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
m := msg.(*ServerReflectionResponse)
// message_response
switch x := m.MessageResponse.(type) {
case *ServerReflectionResponse_FileDescriptorResponse:
b.EncodeVarint(4<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.FileDescriptorResponse); err != nil {
return err
}
case *ServerReflectionResponse_AllExtensionNumbersResponse:
b.EncodeVarint(5<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.AllExtensionNumbersResponse); err != nil {
return err
}
case *ServerReflectionResponse_ListServicesResponse:
b.EncodeVarint(6<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.ListServicesResponse); err != nil {
return err
}
case *ServerReflectionResponse_ErrorResponse:
b.EncodeVarint(7<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.ErrorResponse); err != nil {
return err
}
case nil:
default:
return fmt.Errorf("ServerReflectionResponse.MessageResponse has unexpected type %T", x)
}
return nil
}
func _ServerReflectionResponse_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*ServerReflectionResponse)
switch tag {
case 4: // message_response.file_descriptor_response
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(FileDescriptorResponse)
err := b.DecodeMessage(msg)
m.MessageResponse = &ServerReflectionResponse_FileDescriptorResponse{msg}
return true, err
case 5: // message_response.all_extension_numbers_response
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(ExtensionNumberResponse)
err := b.DecodeMessage(msg)
m.MessageResponse = &ServerReflectionResponse_AllExtensionNumbersResponse{msg}
return true, err
case 6: // message_response.list_services_response
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(ListServiceResponse)
err := b.DecodeMessage(msg)
m.MessageResponse = &ServerReflectionResponse_ListServicesResponse{msg}
return true, err
case 7: // message_response.error_response
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(ErrorResponse)
err := b.DecodeMessage(msg)
m.MessageResponse = &ServerReflectionResponse_ErrorResponse{msg}
return true, err
default:
return false, nil
}
}
func _ServerReflectionResponse_OneofSizer(msg proto.Message) (n int) {
m := msg.(*ServerReflectionResponse)
// message_response
switch x := m.MessageResponse.(type) {
case *ServerReflectionResponse_FileDescriptorResponse:
s := proto.Size(x.FileDescriptorResponse)
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *ServerReflectionResponse_AllExtensionNumbersResponse:
s := proto.Size(x.AllExtensionNumbersResponse)
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *ServerReflectionResponse_ListServicesResponse:
s := proto.Size(x.ListServicesResponse)
n += proto.SizeVarint(6<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *ServerReflectionResponse_ErrorResponse:
s := proto.Size(x.ErrorResponse)
n += proto.SizeVarint(7<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
// Serialized FileDescriptorProto messages sent by the server answering
// a file_by_filename, file_containing_symbol, or file_containing_extension
// request.
type FileDescriptorResponse struct {
// Serialized FileDescriptorProto messages. We avoid taking a dependency on
// descriptor.proto, which uses proto2 only features, by making them opaque
// bytes instead.
FileDescriptorProto [][]byte `protobuf:"bytes,1,rep,name=file_descriptor_proto,json=fileDescriptorProto,proto3" json:"file_descriptor_proto,omitempty"`
}
func (m *FileDescriptorResponse) Reset() { *m = FileDescriptorResponse{} }
func (m *FileDescriptorResponse) String() string { return proto.CompactTextString(m) }
func (*FileDescriptorResponse) ProtoMessage() {}
func (*FileDescriptorResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *FileDescriptorResponse) GetFileDescriptorProto() [][]byte {
if m != nil {
return m.FileDescriptorProto
}
return nil
}
// A list of extension numbers sent by the server answering
// all_extension_numbers_of_type request.
type ExtensionNumberResponse struct {
// Full name of the base type, including the package name. The format
// is <package>.<type>
BaseTypeName string `protobuf:"bytes,1,opt,name=base_type_name,json=baseTypeName" json:"base_type_name,omitempty"`
ExtensionNumber []int32 `protobuf:"varint,2,rep,packed,name=extension_number,json=extensionNumber" json:"extension_number,omitempty"`
}
func (m *ExtensionNumberResponse) Reset() { *m = ExtensionNumberResponse{} }
func (m *ExtensionNumberResponse) String() string { return proto.CompactTextString(m) }
func (*ExtensionNumberResponse) ProtoMessage() {}
func (*ExtensionNumberResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
func (m *ExtensionNumberResponse) GetBaseTypeName() string {
if m != nil {
return m.BaseTypeName
}
return ""
}
func (m *ExtensionNumberResponse) GetExtensionNumber() []int32 {
if m != nil {
return m.ExtensionNumber
}
return nil
}
// A list of ServiceResponse sent by the server answering list_services request.
type ListServiceResponse struct {
// The information of each service may be expanded in the future, so we use
// ServiceResponse message to encapsulate it.
Service []*ServiceResponse `protobuf:"bytes,1,rep,name=service" json:"service,omitempty"`
}
func (m *ListServiceResponse) Reset() { *m = ListServiceResponse{} }
func (m *ListServiceResponse) String() string { return proto.CompactTextString(m) }
func (*ListServiceResponse) ProtoMessage() {}
func (*ListServiceResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
func (m *ListServiceResponse) GetService() []*ServiceResponse {
if m != nil {
return m.Service
}
return nil
}
// The information of a single service used by ListServiceResponse to answer
// list_services request.
type ServiceResponse struct {
// Full name of a registered service, including its package name. The format
// is <package>.<service>
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
}
func (m *ServiceResponse) Reset() { *m = ServiceResponse{} }
func (m *ServiceResponse) String() string { return proto.CompactTextString(m) }
func (*ServiceResponse) ProtoMessage() {}
func (*ServiceResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
func (m *ServiceResponse) GetName() string {
if m != nil {
return m.Name
}
return ""
}
// The error code and error message sent by the server when an error occurs.
type ErrorResponse struct {
// This field uses the error codes defined in grpc::StatusCode.
ErrorCode int32 `protobuf:"varint,1,opt,name=error_code,json=errorCode" json:"error_code,omitempty"`
ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage" json:"error_message,omitempty"`
}
func (m *ErrorResponse) Reset() { *m = ErrorResponse{} }
func (m *ErrorResponse) String() string { return proto.CompactTextString(m) }
func (*ErrorResponse) ProtoMessage() {}
func (*ErrorResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
func (m *ErrorResponse) GetErrorCode() int32 {
if m != nil {
return m.ErrorCode
}
return 0
}
func (m *ErrorResponse) GetErrorMessage() string {
if m != nil {
return m.ErrorMessage
}
return ""
}
func init() {
proto.RegisterType((*ServerReflectionRequest)(nil), "grpc.reflection.v1alpha.ServerReflectionRequest")
proto.RegisterType((*ExtensionRequest)(nil), "grpc.reflection.v1alpha.ExtensionRequest")
proto.RegisterType((*ServerReflectionResponse)(nil), "grpc.reflection.v1alpha.ServerReflectionResponse")
proto.RegisterType((*FileDescriptorResponse)(nil), "grpc.reflection.v1alpha.FileDescriptorResponse")
proto.RegisterType((*ExtensionNumberResponse)(nil), "grpc.reflection.v1alpha.ExtensionNumberResponse")
proto.RegisterType((*ListServiceResponse)(nil), "grpc.reflection.v1alpha.ListServiceResponse")
proto.RegisterType((*ServiceResponse)(nil), "grpc.reflection.v1alpha.ServiceResponse")
proto.RegisterType((*ErrorResponse)(nil), "grpc.reflection.v1alpha.ErrorResponse")
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// Client API for ServerReflection service
type ServerReflectionClient interface {
// The reflection service is structured as a bidirectional stream, ensuring
// all related requests go to a single server.
ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error)
}
type serverReflectionClient struct {
cc *grpc.ClientConn
}
func NewServerReflectionClient(cc *grpc.ClientConn) ServerReflectionClient {
return &serverReflectionClient{cc}
}
func (c *serverReflectionClient) ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error) {
stream, err := grpc.NewClientStream(ctx, &_ServerReflection_serviceDesc.Streams[0], c.cc, "/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo", opts...)
if err != nil {
return nil, err
}
x := &serverReflectionServerReflectionInfoClient{stream}
return x, nil
}
type ServerReflection_ServerReflectionInfoClient interface {
Send(*ServerReflectionRequest) error
Recv() (*ServerReflectionResponse, error)
grpc.ClientStream
}
type serverReflectionServerReflectionInfoClient struct {
grpc.ClientStream
}
func (x *serverReflectionServerReflectionInfoClient) Send(m *ServerReflectionRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *serverReflectionServerReflectionInfoClient) Recv() (*ServerReflectionResponse, error) {
m := new(ServerReflectionResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// Server API for ServerReflection service
type ServerReflectionServer interface {
// The reflection service is structured as a bidirectional stream, ensuring
// all related requests go to a single server.
ServerReflectionInfo(ServerReflection_ServerReflectionInfoServer) error
}
func RegisterServerReflectionServer(s *grpc.Server, srv ServerReflectionServer) {
s.RegisterService(&_ServerReflection_serviceDesc, srv)
}
func _ServerReflection_ServerReflectionInfo_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(ServerReflectionServer).ServerReflectionInfo(&serverReflectionServerReflectionInfoServer{stream})
}
type ServerReflection_ServerReflectionInfoServer interface {
Send(*ServerReflectionResponse) error
Recv() (*ServerReflectionRequest, error)
grpc.ServerStream
}
type serverReflectionServerReflectionInfoServer struct {
grpc.ServerStream
}
func (x *serverReflectionServerReflectionInfoServer) Send(m *ServerReflectionResponse) error {
return x.ServerStream.SendMsg(m)
}
func (x *serverReflectionServerReflectionInfoServer) Recv() (*ServerReflectionRequest, error) {
m := new(ServerReflectionRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
var _ServerReflection_serviceDesc = grpc.ServiceDesc{
ServiceName: "grpc.reflection.v1alpha.ServerReflection",
HandlerType: (*ServerReflectionServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{
{
StreamName: "ServerReflectionInfo",
Handler: _ServerReflection_ServerReflectionInfo_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "grpc_reflection_v1alpha/reflection.proto",
}
func init() { proto.RegisterFile("grpc_reflection_v1alpha/reflection.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 656 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x51, 0x73, 0xd2, 0x40,
0x10, 0x6e, 0x5a, 0x68, 0x87, 0x85, 0x02, 0x5e, 0x2b, 0xa4, 0x3a, 0x75, 0x98, 0x68, 0x35, 0x75,
0x1c, 0xda, 0xe2, 0x8c, 0x3f, 0x80, 0xaa, 0x83, 0x33, 0xb5, 0x75, 0x0e, 0x5f, 0x1c, 0x1f, 0x6e,
0x02, 0x2c, 0x34, 0x1a, 0x72, 0xf1, 0x2e, 0x45, 0x79, 0xf2, 0x47, 0xf8, 0xa3, 0xfc, 0x4b, 0x3e,
0x3a, 0x77, 0x09, 0x21, 0xa4, 0x44, 0xa7, 0x4f, 0x30, 0xdf, 0xee, 0xde, 0xb7, 0xbb, 0xdf, 0xb7,
0x01, 0x7b, 0x22, 0x82, 0x21, 0x13, 0x38, 0xf6, 0x70, 0x18, 0xba, 0xdc, 0x67, 0xb3, 0x33, 0xc7,
0x0b, 0xae, 0x9d, 0x93, 0x25, 0xd4, 0x0e, 0x04, 0x0f, 0x39, 0x69, 0xaa, 0xcc, 0x76, 0x0a, 0x8e,
0x33, 0xad, 0x3f, 0x9b, 0xd0, 0xec, 0xa3, 0x98, 0xa1, 0xa0, 0x49, 0x90, 0xe2, 0xb7, 0x1b, 0x94,
0x21, 0x21, 0x50, 0xb8, 0xe6, 0x32, 0x34, 0x8d, 0x96, 0x61, 0x97, 0xa8, 0xfe, 0x4f, 0x9e, 0x43,
0x7d, 0xec, 0x7a, 0xc8, 0x06, 0x73, 0xa6, 0x7e, 0x7d, 0x67, 0x8a, 0xe6, 0x96, 0x8a, 0xf7, 0x36,
0x68, 0x55, 0x21, 0xdd, 0xf9, 0xdb, 0x18, 0x27, 0xaf, 0xa0, 0xa1, 0x73, 0x87, 0xdc, 0x0f, 0x1d,
0xd7, 0x77, 0xfd, 0x09, 0x93, 0xf3, 0xe9, 0x80, 0x7b, 0x66, 0x21, 0xae, 0xd8, 0x57, 0xf1, 0xf3,
0x24, 0xdc, 0xd7, 0x51, 0x32, 0x81, 0x83, 0x6c, 0x1d, 0xfe, 0x08, 0xd1, 0x97, 0x2e, 0xf7, 0xcd,
0x62, 0xcb, 0xb0, 0xcb, 0x9d, 0xe3, 0x76, 0xce, 0x40, 0xed, 0x37, 0x8b, 0xcc, 0x78, 0x8a, 0xde,
0x06, 0x6d, 0xae, 0xb2, 0x24, 0x19, 0xa4, 0x0b, 0x87, 0x8e, 0xe7, 0x2d, 0x1f, 0x67, 0xfe, 0xcd,
0x74, 0x80, 0x42, 0x32, 0x3e, 0x66, 0xe1, 0x3c, 0x40, 0x73, 0x3b, 0xee, 0xf3, 0xc0, 0xf1, 0xbc,
0xa4, 0xec, 0x32, 0x4a, 0xba, 0x1a, 0x7f, 0x9c, 0x07, 0x48, 0x8e, 0x60, 0xd7, 0x73, 0x65, 0xc8,
0x24, 0x8a, 0x99, 0x3b, 0x44, 0x69, 0xee, 0xc4, 0x35, 0x15, 0x05, 0xf7, 0x63, 0xb4, 0x7b, 0x0f,
0x6a, 0x53, 0x94, 0xd2, 0x99, 0x20, 0x13, 0x51, 0x63, 0xd6, 0x18, 0xea, 0xd9, 0x66, 0xc9, 0x33,
0xa8, 0xa5, 0xa6, 0xd6, 0x3d, 0x44, 0xdb, 0xaf, 0x2e, 0x61, 0x4d, 0x7b, 0x0c, 0xf5, 0x6c, 0xdb,
0xe6, 0x66, 0xcb, 0xb0, 0x8b, 0xb4, 0x86, 0xab, 0x8d, 0x5a, 0xbf, 0x0b, 0x60, 0xde, 0x96, 0x58,
0x06, 0xdc, 0x97, 0x48, 0x0e, 0x01, 0x66, 0x8e, 0xe7, 0x8e, 0x58, 0x4a, 0xe9, 0x92, 0x46, 0x7a,
0x4a, 0xee, 0xcf, 0x50, 0xe7, 0xc2, 0x9d, 0xb8, 0xbe, 0xe3, 0x2d, 0xfa, 0xd6, 0x34, 0xe5, 0xce,
0x69, 0xae, 0x02, 0x39, 0x76, 0xa2, 0xb5, 0xc5, 0x4b, 0x8b, 0x61, 0xbf, 0x82, 0xa9, 0x75, 0x1e,
0xa1, 0x1c, 0x0a, 0x37, 0x08, 0xb9, 0x60, 0x22, 0xee, 0x4b, 0x3b, 0xa4, 0xdc, 0x39, 0xc9, 0x25,
0x51, 0x26, 0x7b, 0x9d, 0xd4, 0x2d, 0xc6, 0xe9, 0x6d, 0x50, 0x6d, 0xb9, 0xdb, 0x11, 0xf2, 0x1d,
0x1e, 0xad, 0xd7, 0x3a, 0xa1, 0x2c, 0xfe, 0x67, 0xae, 0x8c, 0x01, 0x52, 0x9c, 0x0f, 0xd7, 0xd8,
0x23, 0x21, 0x1e, 0x41, 0x63, 0xc5, 0x20, 0x4b, 0xc2, 0x6d, 0x4d, 0xf8, 0x22, 0x97, 0xf0, 0x62,
0x69, 0xa0, 0x14, 0xd9, 0x7e, 0xda, 0x57, 0x09, 0xcb, 0x15, 0x54, 0x51, 0x88, 0xf4, 0x06, 0x77,
0xf4, 0xeb, 0x4f, 0xf3, 0xc7, 0x51, 0xe9, 0xa9, 0x77, 0x77, 0x31, 0x0d, 0x74, 0x09, 0xd4, 0x97,
0x86, 0x8d, 0x30, 0xeb, 0x02, 0x1a, 0xeb, 0xf7, 0x4e, 0x3a, 0x70, 0x3f, 0x2b, 0xa5, 0xfe, 0xf0,
0x98, 0x46, 0x6b, 0xcb, 0xae, 0xd0, 0xbd, 0x55, 0x51, 0x3e, 0xa8, 0x90, 0xf5, 0x05, 0x9a, 0x39,
0x2b, 0x25, 0x4f, 0xa0, 0x3a, 0x70, 0x24, 0xea, 0x03, 0x60, 0xfa, 0x1b, 0x13, 0x39, 0xb3, 0xa2,
0x50, 0xe5, 0xff, 0x4b, 0xf5, 0x7d, 0x59, 0x7f, 0x03, 0x5b, 0xeb, 0x6e, 0xe0, 0x13, 0xec, 0xad,
0xd9, 0x26, 0xe9, 0xc2, 0x4e, 0x2c, 0x8b, 0x6e, 0xb4, 0xdc, 0xb1, 0xff, 0xe9, 0xea, 0x54, 0x29,
0x5d, 0x14, 0x5a, 0x47, 0x50, 0xcb, 0x3e, 0x4b, 0xa0, 0x90, 0x6a, 0x5a, 0xff, 0xb7, 0xfa, 0xb0,
0xbb, 0xb2, 0x71, 0x75, 0x79, 0x91, 0x62, 0x43, 0x3e, 0x8a, 0x52, 0x8b, 0xb4, 0xa4, 0x91, 0x73,
0x3e, 0x42, 0xf2, 0x18, 0x22, 0x41, 0x58, 0xac, 0x82, 0x3e, 0xbb, 0x12, 0xad, 0x68, 0xf0, 0x7d,
0x84, 0x75, 0x7e, 0x19, 0x50, 0xcf, 0x9e, 0x1b, 0xf9, 0x09, 0xfb, 0x59, 0xec, 0x9d, 0x3f, 0xe6,
0xe4, 0xce, 0x17, 0xfb, 0xe0, 0xec, 0x0e, 0x15, 0xd1, 0x54, 0xb6, 0x71, 0x6a, 0x0c, 0xb6, 0xb5,
0xf4, 0x2f, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x85, 0x02, 0x09, 0x9d, 0x9f, 0x06, 0x00, 0x00,
}

View File

@ -0,0 +1,136 @@
// Copyright 2016 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Service exported by server reflection
syntax = "proto3";
package grpc.reflection.v1alpha;
service ServerReflection {
// The reflection service is structured as a bidirectional stream, ensuring
// all related requests go to a single server.
rpc ServerReflectionInfo(stream ServerReflectionRequest)
returns (stream ServerReflectionResponse);
}
// The message sent by the client when calling ServerReflectionInfo method.
message ServerReflectionRequest {
string host = 1;
// To use reflection service, the client should set one of the following
// fields in message_request. The server distinguishes requests by their
// defined field and then handles them using corresponding methods.
oneof message_request {
// Find a proto file by the file name.
string file_by_filename = 3;
// Find the proto file that declares the given fully-qualified symbol name.
// This field should be a fully-qualified symbol name
// (e.g. <package>.<service>[.<method>] or <package>.<type>).
string file_containing_symbol = 4;
// Find the proto file which defines an extension extending the given
// message type with the given field number.
ExtensionRequest file_containing_extension = 5;
// Finds the tag numbers used by all known extensions of extendee_type, and
// appends them to ExtensionNumberResponse in an undefined order.
// Its corresponding method is best-effort: it's not guaranteed that the
// reflection service will implement this method, and it's not guaranteed
// that this method will provide all extensions. Returns
// StatusCode::UNIMPLEMENTED if it's not implemented.
// This field should be a fully-qualified type name. The format is
// <package>.<type>
string all_extension_numbers_of_type = 6;
// List the full names of registered services. The content will not be
// checked.
string list_services = 7;
}
}
// The type name and extension number sent by the client when requesting
// file_containing_extension.
message ExtensionRequest {
// Fully-qualified type name. The format should be <package>.<type>
string containing_type = 1;
int32 extension_number = 2;
}
// The message sent by the server to answer ServerReflectionInfo method.
message ServerReflectionResponse {
string valid_host = 1;
ServerReflectionRequest original_request = 2;
// The server set one of the following fields according to the message_request
// in the request.
oneof message_response {
// This message is used to answer file_by_filename, file_containing_symbol,
// file_containing_extension requests with transitive dependencies. As
// the repeated label is not allowed in oneof fields, we use a
// FileDescriptorResponse message to encapsulate the repeated fields.
// The reflection service is allowed to avoid sending FileDescriptorProtos
// that were previously sent in response to earlier requests in the stream.
FileDescriptorResponse file_descriptor_response = 4;
// This message is used to answer all_extension_numbers_of_type requst.
ExtensionNumberResponse all_extension_numbers_response = 5;
// This message is used to answer list_services request.
ListServiceResponse list_services_response = 6;
// This message is used when an error occurs.
ErrorResponse error_response = 7;
}
}
// Serialized FileDescriptorProto messages sent by the server answering
// a file_by_filename, file_containing_symbol, or file_containing_extension
// request.
message FileDescriptorResponse {
// Serialized FileDescriptorProto messages. We avoid taking a dependency on
// descriptor.proto, which uses proto2 only features, by making them opaque
// bytes instead.
repeated bytes file_descriptor_proto = 1;
}
// A list of extension numbers sent by the server answering
// all_extension_numbers_of_type request.
message ExtensionNumberResponse {
// Full name of the base type, including the package name. The format
// is <package>.<type>
string base_type_name = 1;
repeated int32 extension_number = 2;
}
// A list of ServiceResponse sent by the server answering list_services request.
message ListServiceResponse {
// The information of each service may be expanded in the future, so we use
// ServiceResponse message to encapsulate it.
repeated ServiceResponse service = 1;
}
// The information of a single service used by ListServiceResponse to answer
// list_services request.
message ServiceResponse {
// Full name of a registered service, including its package name. The format
// is <package>.<service>
string name = 1;
}
// The error code and error message sent by the server when an error occurs.
message ErrorResponse {
// This field uses the error codes defined in grpc::StatusCode.
int32 error_code = 1;
string error_message = 2;
}

View File

@ -0,0 +1,77 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: proto2.proto
/*
Package grpc_testing is a generated protocol buffer package.
It is generated from these files:
proto2.proto
proto2_ext.proto
proto2_ext2.proto
test.proto
It has these top-level messages:
ToBeExtended
Extension
AnotherExtension
SearchResponse
SearchRequest
*/
package grpc_testing
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type ToBeExtended struct {
Foo *int32 `protobuf:"varint,1,req,name=foo" json:"foo,omitempty"`
proto.XXX_InternalExtensions `json:"-"`
XXX_unrecognized []byte `json:"-"`
}
func (m *ToBeExtended) Reset() { *m = ToBeExtended{} }
func (m *ToBeExtended) String() string { return proto.CompactTextString(m) }
func (*ToBeExtended) ProtoMessage() {}
func (*ToBeExtended) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
var extRange_ToBeExtended = []proto.ExtensionRange{
{10, 30},
}
func (*ToBeExtended) ExtensionRangeArray() []proto.ExtensionRange {
return extRange_ToBeExtended
}
func (m *ToBeExtended) GetFoo() int32 {
if m != nil && m.Foo != nil {
return *m.Foo
}
return 0
}
func init() {
proto.RegisterType((*ToBeExtended)(nil), "grpc.testing.ToBeExtended")
}
func init() { proto.RegisterFile("proto2.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 86 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x29, 0x28, 0xca, 0x2f,
0xc9, 0x37, 0xd2, 0x03, 0x53, 0x42, 0x3c, 0xe9, 0x45, 0x05, 0xc9, 0x7a, 0x25, 0xa9, 0xc5, 0x25,
0x99, 0x79, 0xe9, 0x4a, 0x6a, 0x5c, 0x3c, 0x21, 0xf9, 0x4e, 0xa9, 0xae, 0x15, 0x25, 0xa9, 0x79,
0x29, 0xa9, 0x29, 0x42, 0x02, 0x5c, 0xcc, 0x69, 0xf9, 0xf9, 0x12, 0x8c, 0x0a, 0x4c, 0x1a, 0xac,
0x41, 0x20, 0xa6, 0x16, 0x0b, 0x07, 0x97, 0x80, 0x3c, 0x20, 0x00, 0x00, 0xff, 0xff, 0x74, 0x86,
0x9c, 0x08, 0x44, 0x00, 0x00, 0x00,
}

View File

@ -0,0 +1,22 @@
// Copyright 2017 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto2";
package grpc.testing;
message ToBeExtended {
required int32 foo = 1;
extensions 10 to 30;
}

View File

@ -0,0 +1,82 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: proto2_ext.proto
package grpc_testing
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
type Extension struct {
Whatzit *int32 `protobuf:"varint,1,opt,name=whatzit" json:"whatzit,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Extension) Reset() { *m = Extension{} }
func (m *Extension) String() string { return proto.CompactTextString(m) }
func (*Extension) ProtoMessage() {}
func (*Extension) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} }
func (m *Extension) GetWhatzit() int32 {
if m != nil && m.Whatzit != nil {
return *m.Whatzit
}
return 0
}
var E_Foo = &proto.ExtensionDesc{
ExtendedType: (*ToBeExtended)(nil),
ExtensionType: (*int32)(nil),
Field: 13,
Name: "grpc.testing.foo",
Tag: "varint,13,opt,name=foo",
Filename: "proto2_ext.proto",
}
var E_Bar = &proto.ExtensionDesc{
ExtendedType: (*ToBeExtended)(nil),
ExtensionType: (*Extension)(nil),
Field: 17,
Name: "grpc.testing.bar",
Tag: "bytes,17,opt,name=bar",
Filename: "proto2_ext.proto",
}
var E_Baz = &proto.ExtensionDesc{
ExtendedType: (*ToBeExtended)(nil),
ExtensionType: (*SearchRequest)(nil),
Field: 19,
Name: "grpc.testing.baz",
Tag: "bytes,19,opt,name=baz",
Filename: "proto2_ext.proto",
}
func init() {
proto.RegisterType((*Extension)(nil), "grpc.testing.Extension")
proto.RegisterExtension(E_Foo)
proto.RegisterExtension(E_Bar)
proto.RegisterExtension(E_Baz)
}
func init() { proto.RegisterFile("proto2_ext.proto", fileDescriptor1) }
var fileDescriptor1 = []byte{
// 179 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x28, 0x28, 0xca, 0x2f,
0xc9, 0x37, 0x8a, 0x4f, 0xad, 0x28, 0xd1, 0x03, 0x33, 0x85, 0x78, 0xd2, 0x8b, 0x0a, 0x92, 0xf5,
0x4a, 0x52, 0x8b, 0x4b, 0x32, 0xf3, 0xd2, 0xa5, 0x78, 0x20, 0xf2, 0x10, 0x39, 0x29, 0x2e, 0x90,
0x30, 0x84, 0xad, 0xa4, 0xca, 0xc5, 0xe9, 0x5a, 0x51, 0x92, 0x9a, 0x57, 0x9c, 0x99, 0x9f, 0x27,
0x24, 0xc1, 0xc5, 0x5e, 0x9e, 0x91, 0x58, 0x52, 0x95, 0x59, 0x22, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1,
0x1a, 0x04, 0xe3, 0x5a, 0xe9, 0x70, 0x31, 0xa7, 0xe5, 0xe7, 0x0b, 0x49, 0xe9, 0x21, 0x1b, 0xab,
0x17, 0x92, 0xef, 0x94, 0x0a, 0xd6, 0x9d, 0x92, 0x9a, 0x22, 0xc1, 0x0b, 0xd6, 0x01, 0x52, 0x66,
0xe5, 0xca, 0xc5, 0x9c, 0x94, 0x58, 0x84, 0x57, 0xb5, 0xa0, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0x38,
0xaa, 0x0a, 0xb8, 0x4b, 0x82, 0x40, 0xfa, 0xad, 0x3c, 0x41, 0xc6, 0x54, 0xe1, 0x35, 0x46, 0x18,
0x6c, 0x8c, 0x34, 0xaa, 0x8a, 0xe0, 0xd4, 0xc4, 0xa2, 0xe4, 0x8c, 0xa0, 0xd4, 0xc2, 0xd2, 0xd4,
0xe2, 0x12, 0x90, 0x51, 0x55, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x71, 0x6b, 0x94, 0x9f, 0x21,
0x01, 0x00, 0x00,
}

View File

@ -0,0 +1,30 @@
// Copyright 2017 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto2";
package grpc.testing;
import "proto2.proto";
import "test.proto";
extend ToBeExtended {
optional int32 foo = 13;
optional Extension bar = 17;
optional SearchRequest baz = 19;
}
message Extension {
optional int32 whatzit = 1;
}

View File

@ -0,0 +1,71 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: proto2_ext2.proto
package grpc_testing
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
type AnotherExtension struct {
Whatchamacallit *int32 `protobuf:"varint,1,opt,name=whatchamacallit" json:"whatchamacallit,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *AnotherExtension) Reset() { *m = AnotherExtension{} }
func (m *AnotherExtension) String() string { return proto.CompactTextString(m) }
func (*AnotherExtension) ProtoMessage() {}
func (*AnotherExtension) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{0} }
func (m *AnotherExtension) GetWhatchamacallit() int32 {
if m != nil && m.Whatchamacallit != nil {
return *m.Whatchamacallit
}
return 0
}
var E_Frob = &proto.ExtensionDesc{
ExtendedType: (*ToBeExtended)(nil),
ExtensionType: (*string)(nil),
Field: 23,
Name: "grpc.testing.frob",
Tag: "bytes,23,opt,name=frob",
Filename: "proto2_ext2.proto",
}
var E_Nitz = &proto.ExtensionDesc{
ExtendedType: (*ToBeExtended)(nil),
ExtensionType: (*AnotherExtension)(nil),
Field: 29,
Name: "grpc.testing.nitz",
Tag: "bytes,29,opt,name=nitz",
Filename: "proto2_ext2.proto",
}
func init() {
proto.RegisterType((*AnotherExtension)(nil), "grpc.testing.AnotherExtension")
proto.RegisterExtension(E_Frob)
proto.RegisterExtension(E_Nitz)
}
func init() { proto.RegisterFile("proto2_ext2.proto", fileDescriptor2) }
var fileDescriptor2 = []byte{
// 165 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0x28, 0xca, 0x2f,
0xc9, 0x37, 0x8a, 0x4f, 0xad, 0x28, 0x31, 0xd2, 0x03, 0xb3, 0x85, 0x78, 0xd2, 0x8b, 0x0a, 0x92,
0xf5, 0x4a, 0x52, 0x8b, 0x4b, 0x32, 0xf3, 0xd2, 0xa5, 0x78, 0x20, 0x0a, 0x20, 0x72, 0x4a, 0x36,
0x5c, 0x02, 0x8e, 0x79, 0xf9, 0x25, 0x19, 0xa9, 0x45, 0xae, 0x15, 0x25, 0xa9, 0x79, 0xc5, 0x99,
0xf9, 0x79, 0x42, 0x1a, 0x5c, 0xfc, 0xe5, 0x19, 0x89, 0x25, 0xc9, 0x19, 0x89, 0xb9, 0x89, 0xc9,
0x89, 0x39, 0x39, 0x99, 0x25, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xac, 0x41, 0xe8, 0xc2, 0x56, 0x7a,
0x5c, 0x2c, 0x69, 0x45, 0xf9, 0x49, 0x42, 0x52, 0x7a, 0xc8, 0x56, 0xe8, 0x85, 0xe4, 0x3b, 0xa5,
0x82, 0x8d, 0x4b, 0x49, 0x4d, 0x91, 0x10, 0x57, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xab, 0xb3, 0xf2,
0xe3, 0x62, 0xc9, 0xcb, 0x2c, 0xa9, 0xc2, 0xab, 0x5e, 0x56, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x0e,
0x55, 0x05, 0xba, 0x1b, 0x83, 0xc0, 0xe6, 0x00, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x7e, 0x0d,
0x26, 0xed, 0x00, 0x00, 0x00,
}

View File

@ -0,0 +1,28 @@
// Copyright 2017 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto2";
package grpc.testing;
import "proto2.proto";
extend ToBeExtended {
optional string frob = 23;
optional AnotherExtension nitz = 29;
}
message AnotherExtension {
optional int32 whatchamacallit = 1;
}

View File

@ -0,0 +1,247 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: test.proto
package grpc_testing
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import (
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
type SearchResponse struct {
Results []*SearchResponse_Result `protobuf:"bytes,1,rep,name=results" json:"results,omitempty"`
}
func (m *SearchResponse) Reset() { *m = SearchResponse{} }
func (m *SearchResponse) String() string { return proto.CompactTextString(m) }
func (*SearchResponse) ProtoMessage() {}
func (*SearchResponse) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{0} }
func (m *SearchResponse) GetResults() []*SearchResponse_Result {
if m != nil {
return m.Results
}
return nil
}
type SearchResponse_Result struct {
Url string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"`
Title string `protobuf:"bytes,2,opt,name=title" json:"title,omitempty"`
Snippets []string `protobuf:"bytes,3,rep,name=snippets" json:"snippets,omitempty"`
}
func (m *SearchResponse_Result) Reset() { *m = SearchResponse_Result{} }
func (m *SearchResponse_Result) String() string { return proto.CompactTextString(m) }
func (*SearchResponse_Result) ProtoMessage() {}
func (*SearchResponse_Result) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{0, 0} }
func (m *SearchResponse_Result) GetUrl() string {
if m != nil {
return m.Url
}
return ""
}
func (m *SearchResponse_Result) GetTitle() string {
if m != nil {
return m.Title
}
return ""
}
func (m *SearchResponse_Result) GetSnippets() []string {
if m != nil {
return m.Snippets
}
return nil
}
type SearchRequest struct {
Query string `protobuf:"bytes,1,opt,name=query" json:"query,omitempty"`
}
func (m *SearchRequest) Reset() { *m = SearchRequest{} }
func (m *SearchRequest) String() string { return proto.CompactTextString(m) }
func (*SearchRequest) ProtoMessage() {}
func (*SearchRequest) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{1} }
func (m *SearchRequest) GetQuery() string {
if m != nil {
return m.Query
}
return ""
}
func init() {
proto.RegisterType((*SearchResponse)(nil), "grpc.testing.SearchResponse")
proto.RegisterType((*SearchResponse_Result)(nil), "grpc.testing.SearchResponse.Result")
proto.RegisterType((*SearchRequest)(nil), "grpc.testing.SearchRequest")
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// Client API for SearchService service
type SearchServiceClient interface {
Search(ctx context.Context, in *SearchRequest, opts ...grpc.CallOption) (*SearchResponse, error)
StreamingSearch(ctx context.Context, opts ...grpc.CallOption) (SearchService_StreamingSearchClient, error)
}
type searchServiceClient struct {
cc *grpc.ClientConn
}
func NewSearchServiceClient(cc *grpc.ClientConn) SearchServiceClient {
return &searchServiceClient{cc}
}
func (c *searchServiceClient) Search(ctx context.Context, in *SearchRequest, opts ...grpc.CallOption) (*SearchResponse, error) {
out := new(SearchResponse)
err := grpc.Invoke(ctx, "/grpc.testing.SearchService/Search", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *searchServiceClient) StreamingSearch(ctx context.Context, opts ...grpc.CallOption) (SearchService_StreamingSearchClient, error) {
stream, err := grpc.NewClientStream(ctx, &_SearchService_serviceDesc.Streams[0], c.cc, "/grpc.testing.SearchService/StreamingSearch", opts...)
if err != nil {
return nil, err
}
x := &searchServiceStreamingSearchClient{stream}
return x, nil
}
type SearchService_StreamingSearchClient interface {
Send(*SearchRequest) error
Recv() (*SearchResponse, error)
grpc.ClientStream
}
type searchServiceStreamingSearchClient struct {
grpc.ClientStream
}
func (x *searchServiceStreamingSearchClient) Send(m *SearchRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *searchServiceStreamingSearchClient) Recv() (*SearchResponse, error) {
m := new(SearchResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// Server API for SearchService service
type SearchServiceServer interface {
Search(context.Context, *SearchRequest) (*SearchResponse, error)
StreamingSearch(SearchService_StreamingSearchServer) error
}
func RegisterSearchServiceServer(s *grpc.Server, srv SearchServiceServer) {
s.RegisterService(&_SearchService_serviceDesc, srv)
}
func _SearchService_Search_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SearchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SearchServiceServer).Search(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.testing.SearchService/Search",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SearchServiceServer).Search(ctx, req.(*SearchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _SearchService_StreamingSearch_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(SearchServiceServer).StreamingSearch(&searchServiceStreamingSearchServer{stream})
}
type SearchService_StreamingSearchServer interface {
Send(*SearchResponse) error
Recv() (*SearchRequest, error)
grpc.ServerStream
}
type searchServiceStreamingSearchServer struct {
grpc.ServerStream
}
func (x *searchServiceStreamingSearchServer) Send(m *SearchResponse) error {
return x.ServerStream.SendMsg(m)
}
func (x *searchServiceStreamingSearchServer) Recv() (*SearchRequest, error) {
m := new(SearchRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
var _SearchService_serviceDesc = grpc.ServiceDesc{
ServiceName: "grpc.testing.SearchService",
HandlerType: (*SearchServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Search",
Handler: _SearchService_Search_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "StreamingSearch",
Handler: _SearchService_StreamingSearch_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "test.proto",
}
func init() { proto.RegisterFile("test.proto", fileDescriptor3) }
var fileDescriptor3 = []byte{
// 231 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x91, 0xbd, 0x4a, 0xc5, 0x40,
0x10, 0x85, 0x59, 0x83, 0xd1, 0x3b, 0xfe, 0x32, 0x58, 0x84, 0x68, 0x11, 0xae, 0x08, 0xa9, 0x16,
0xb9, 0xd6, 0x56, 0xb6, 0x16, 0xb2, 0x79, 0x82, 0x6b, 0x18, 0xe2, 0x42, 0x4c, 0x36, 0x33, 0x13,
0xc1, 0x87, 0xb1, 0xf5, 0x39, 0x25, 0x59, 0x23, 0x0a, 0x62, 0x63, 0xb7, 0xe7, 0xe3, 0xcc, 0xb7,
0xbb, 0x0c, 0x80, 0x92, 0xa8, 0x0d, 0xdc, 0x6b, 0x8f, 0x87, 0x0d, 0x87, 0xda, 0x4e, 0xc0, 0x77,
0xcd, 0xfa, 0xcd, 0xc0, 0x71, 0x45, 0x5b, 0xae, 0x9f, 0x1c, 0x49, 0xe8, 0x3b, 0x21, 0xbc, 0x85,
0x3d, 0x26, 0x19, 0x5b, 0x95, 0xcc, 0x14, 0x49, 0x79, 0xb0, 0xb9, 0xb4, 0xdf, 0x47, 0xec, 0xcf,
0xba, 0x75, 0x73, 0xd7, 0x2d, 0x33, 0xf9, 0x3d, 0xa4, 0x11, 0xe1, 0x29, 0x24, 0x23, 0xb7, 0x99,
0x29, 0x4c, 0xb9, 0x72, 0xd3, 0x11, 0xcf, 0x60, 0x57, 0xbd, 0xb6, 0x94, 0xed, 0xcc, 0x2c, 0x06,
0xcc, 0x61, 0x5f, 0x3a, 0x1f, 0x02, 0xa9, 0x64, 0x49, 0x91, 0x94, 0x2b, 0xf7, 0x95, 0xd7, 0x57,
0x70, 0xb4, 0xdc, 0x37, 0x8c, 0x24, 0x3a, 0x29, 0x86, 0x91, 0xf8, 0xf5, 0x53, 0x1b, 0xc3, 0xe6,
0xdd, 0x2c, 0xbd, 0x8a, 0xf8, 0xc5, 0xd7, 0x84, 0x77, 0x90, 0x46, 0x80, 0xe7, 0xbf, 0x3f, 0x7f,
0xd6, 0xe5, 0x17, 0x7f, 0xfd, 0x0d, 0x1f, 0xe0, 0xa4, 0x52, 0xa6, 0xed, 0xb3, 0xef, 0x9a, 0x7f,
0xdb, 0x4a, 0x73, 0x6d, 0x1e, 0xd3, 0x79, 0x09, 0x37, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x20,
0xd6, 0x09, 0xb8, 0x92, 0x01, 0x00, 0x00,
}

View File

@ -0,0 +1,35 @@
// Copyright 2017 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package grpc.testing;
message SearchResponse {
message Result {
string url = 1;
string title = 2;
repeated string snippets = 3;
}
repeated Result results = 1;
}
message SearchRequest {
string query = 1;
}
service SearchService {
rpc Search(SearchRequest) returns (SearchResponse);
rpc StreamingSearch(stream SearchRequest) returns (stream SearchResponse);
}

View File

@ -0,0 +1,236 @@
// Code generated by protoc-gen-go.
// source: testv3.proto
// DO NOT EDIT!
/*
Package grpc_testingv3 is a generated protocol buffer package.
It is generated from these files:
testv3.proto
It has these top-level messages:
SearchResponseV3
SearchRequestV3
*/
package grpc_testingv3
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import (
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type SearchResponseV3 struct {
Results []*SearchResponseV3_Result `protobuf:"bytes,1,rep,name=results" json:"results,omitempty"`
}
func (m *SearchResponseV3) Reset() { *m = SearchResponseV3{} }
func (m *SearchResponseV3) String() string { return proto.CompactTextString(m) }
func (*SearchResponseV3) ProtoMessage() {}
func (*SearchResponseV3) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *SearchResponseV3) GetResults() []*SearchResponseV3_Result {
if m != nil {
return m.Results
}
return nil
}
type SearchResponseV3_Result struct {
Url string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"`
Title string `protobuf:"bytes,2,opt,name=title" json:"title,omitempty"`
Snippets []string `protobuf:"bytes,3,rep,name=snippets" json:"snippets,omitempty"`
}
func (m *SearchResponseV3_Result) Reset() { *m = SearchResponseV3_Result{} }
func (m *SearchResponseV3_Result) String() string { return proto.CompactTextString(m) }
func (*SearchResponseV3_Result) ProtoMessage() {}
func (*SearchResponseV3_Result) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0, 0} }
type SearchRequestV3 struct {
Query string `protobuf:"bytes,1,opt,name=query" json:"query,omitempty"`
}
func (m *SearchRequestV3) Reset() { *m = SearchRequestV3{} }
func (m *SearchRequestV3) String() string { return proto.CompactTextString(m) }
func (*SearchRequestV3) ProtoMessage() {}
func (*SearchRequestV3) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func init() {
proto.RegisterType((*SearchResponseV3)(nil), "grpc.testingv3.SearchResponseV3")
proto.RegisterType((*SearchResponseV3_Result)(nil), "grpc.testingv3.SearchResponseV3.Result")
proto.RegisterType((*SearchRequestV3)(nil), "grpc.testingv3.SearchRequestV3")
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion3
// Client API for SearchServiceV3 service
type SearchServiceV3Client interface {
Search(ctx context.Context, in *SearchRequestV3, opts ...grpc.CallOption) (*SearchResponseV3, error)
StreamingSearch(ctx context.Context, opts ...grpc.CallOption) (SearchServiceV3_StreamingSearchClient, error)
}
type searchServiceV3Client struct {
cc *grpc.ClientConn
}
func NewSearchServiceV3Client(cc *grpc.ClientConn) SearchServiceV3Client {
return &searchServiceV3Client{cc}
}
func (c *searchServiceV3Client) Search(ctx context.Context, in *SearchRequestV3, opts ...grpc.CallOption) (*SearchResponseV3, error) {
out := new(SearchResponseV3)
err := grpc.Invoke(ctx, "/grpc.testingv3.SearchServiceV3/Search", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *searchServiceV3Client) StreamingSearch(ctx context.Context, opts ...grpc.CallOption) (SearchServiceV3_StreamingSearchClient, error) {
stream, err := grpc.NewClientStream(ctx, &_SearchServiceV3_serviceDesc.Streams[0], c.cc, "/grpc.testingv3.SearchServiceV3/StreamingSearch", opts...)
if err != nil {
return nil, err
}
x := &searchServiceV3StreamingSearchClient{stream}
return x, nil
}
type SearchServiceV3_StreamingSearchClient interface {
Send(*SearchRequestV3) error
Recv() (*SearchResponseV3, error)
grpc.ClientStream
}
type searchServiceV3StreamingSearchClient struct {
grpc.ClientStream
}
func (x *searchServiceV3StreamingSearchClient) Send(m *SearchRequestV3) error {
return x.ClientStream.SendMsg(m)
}
func (x *searchServiceV3StreamingSearchClient) Recv() (*SearchResponseV3, error) {
m := new(SearchResponseV3)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// Server API for SearchServiceV3 service
type SearchServiceV3Server interface {
Search(context.Context, *SearchRequestV3) (*SearchResponseV3, error)
StreamingSearch(SearchServiceV3_StreamingSearchServer) error
}
func RegisterSearchServiceV3Server(s *grpc.Server, srv SearchServiceV3Server) {
s.RegisterService(&_SearchServiceV3_serviceDesc, srv)
}
func _SearchServiceV3_Search_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SearchRequestV3)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SearchServiceV3Server).Search(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.testingv3.SearchServiceV3/Search",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SearchServiceV3Server).Search(ctx, req.(*SearchRequestV3))
}
return interceptor(ctx, in, info, handler)
}
func _SearchServiceV3_StreamingSearch_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(SearchServiceV3Server).StreamingSearch(&searchServiceV3StreamingSearchServer{stream})
}
type SearchServiceV3_StreamingSearchServer interface {
Send(*SearchResponseV3) error
Recv() (*SearchRequestV3, error)
grpc.ServerStream
}
type searchServiceV3StreamingSearchServer struct {
grpc.ServerStream
}
func (x *searchServiceV3StreamingSearchServer) Send(m *SearchResponseV3) error {
return x.ServerStream.SendMsg(m)
}
func (x *searchServiceV3StreamingSearchServer) Recv() (*SearchRequestV3, error) {
m := new(SearchRequestV3)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
var _SearchServiceV3_serviceDesc = grpc.ServiceDesc{
ServiceName: "grpc.testingv3.SearchServiceV3",
HandlerType: (*SearchServiceV3Server)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Search",
Handler: _SearchServiceV3_Search_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "StreamingSearch",
Handler: _SearchServiceV3_StreamingSearch_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: fileDescriptor0,
}
func init() { proto.RegisterFile("testv3.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 240 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x91, 0x41, 0x4b, 0xc3, 0x40,
0x10, 0x85, 0x59, 0x83, 0xd1, 0x8e, 0x62, 0xcb, 0xe2, 0x21, 0xe4, 0x62, 0xe8, 0xa5, 0x39, 0x2d,
0xd2, 0xfd, 0x05, 0x9e, 0xf5, 0xb4, 0x81, 0xe2, 0xb5, 0x86, 0x21, 0x2e, 0xc4, 0x64, 0x3b, 0x33,
0x09, 0xf8, 0x7b, 0xfc, 0x13, 0xfe, 0x3c, 0x49, 0xd2, 0x08, 0x0a, 0xe2, 0xa5, 0xb7, 0x7d, 0x8f,
0xf7, 0xbe, 0xe5, 0x31, 0x70, 0x2d, 0xc8, 0xd2, 0x5b, 0x13, 0xa8, 0x95, 0x56, 0xdf, 0x54, 0x14,
0x4a, 0x33, 0x58, 0xbe, 0xa9, 0x7a, 0xbb, 0xfe, 0x50, 0xb0, 0x2a, 0x70, 0x4f, 0xe5, 0xab, 0x43,
0x0e, 0x6d, 0xc3, 0xb8, 0xb3, 0xfa, 0x01, 0x2e, 0x08, 0xb9, 0xab, 0x85, 0x13, 0x95, 0x45, 0xf9,
0xd5, 0x76, 0x63, 0x7e, 0xd6, 0xcc, 0xef, 0x8a, 0x71, 0x63, 0xde, 0xcd, 0xbd, 0xf4, 0x09, 0xe2,
0xc9, 0xd2, 0x2b, 0x88, 0x3a, 0xaa, 0x13, 0x95, 0xa9, 0x7c, 0xe1, 0x86, 0xa7, 0xbe, 0x85, 0x73,
0xf1, 0x52, 0x63, 0x72, 0x36, 0x7a, 0x93, 0xd0, 0x29, 0x5c, 0x72, 0xe3, 0x43, 0x40, 0xe1, 0x24,
0xca, 0xa2, 0x7c, 0xe1, 0xbe, 0xf5, 0x7a, 0x03, 0xcb, 0xf9, 0xc7, 0x43, 0x87, 0x2c, 0x3b, 0x3b,
0x40, 0x0e, 0x1d, 0xd2, 0xfb, 0x11, 0x3c, 0x89, 0xed, 0xa7, 0x9a, 0x93, 0x05, 0x52, 0xef, 0xcb,
0x61, 0xcd, 0x23, 0xc4, 0x93, 0xa5, 0xef, 0xfe, 0x9a, 0x71, 0x84, 0xa6, 0xd9, 0x7f, 0x3b, 0xf5,
0x33, 0x2c, 0x0b, 0x21, 0xdc, 0xbf, 0xf9, 0xa6, 0x3a, 0x19, 0x35, 0x57, 0xf7, 0xea, 0x25, 0x1e,
0x0f, 0x64, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xd4, 0xe6, 0xa0, 0xf9, 0xb0, 0x01, 0x00, 0x00,
}

View File

@ -0,0 +1,21 @@
syntax = "proto3";
package grpc.testingv3;
message SearchResponseV3 {
message Result {
string url = 1;
string title = 2;
repeated string snippets = 3;
}
repeated Result results = 1;
}
message SearchRequestV3 {
string query = 1;
}
service SearchServiceV3 {
rpc Search(SearchRequestV3) returns (SearchResponseV3);
rpc StreamingSearch(stream SearchRequestV3) returns (stream SearchResponseV3);
}

View File

@ -0,0 +1,399 @@
/*
*
* Copyright 2016 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
//go:generate protoc --go_out=plugins=grpc:. grpc_reflection_v1alpha/reflection.proto
/*
Package reflection implements server reflection service.
The service implemented is defined in:
https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto.
To register server reflection on a gRPC server:
import "google.golang.org/grpc/reflection"
s := grpc.NewServer()
pb.RegisterYourOwnServer(s, &server{})
// Register reflection service on gRPC server.
reflection.Register(s)
s.Serve(lis)
*/
package reflection // import "google.golang.org/grpc/reflection"
import (
"bytes"
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"reflect"
"strings"
"github.com/golang/protobuf/proto"
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"
"google.golang.org/grpc/status"
)
type serverReflectionServer struct {
s *grpc.Server
// TODO add more cache if necessary
serviceInfo map[string]grpc.ServiceInfo // cache for s.GetServiceInfo()
}
// Register registers the server reflection service on the given gRPC server.
func Register(s *grpc.Server) {
rpb.RegisterServerReflectionServer(s, &serverReflectionServer{
s: s,
})
}
// protoMessage is used for type assertion on proto messages.
// Generated proto message implements function Descriptor(), but Descriptor()
// is not part of interface proto.Message. This interface is needed to
// call Descriptor().
type protoMessage interface {
Descriptor() ([]byte, []int)
}
// fileDescForType gets the file descriptor for the given type.
// The given type should be a proto message.
func (s *serverReflectionServer) fileDescForType(st reflect.Type) (*dpb.FileDescriptorProto, error) {
m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(protoMessage)
if !ok {
return nil, fmt.Errorf("failed to create message from type: %v", st)
}
enc, _ := m.Descriptor()
return s.decodeFileDesc(enc)
}
// decodeFileDesc does decompression and unmarshalling on the given
// file descriptor byte slice.
func (s *serverReflectionServer) decodeFileDesc(enc []byte) (*dpb.FileDescriptorProto, error) {
raw, err := decompress(enc)
if err != nil {
return nil, fmt.Errorf("failed to decompress enc: %v", err)
}
fd := new(dpb.FileDescriptorProto)
if err := proto.Unmarshal(raw, fd); err != nil {
return nil, fmt.Errorf("bad descriptor: %v", err)
}
return fd, nil
}
// decompress does gzip decompression.
func decompress(b []byte) ([]byte, error) {
r, err := gzip.NewReader(bytes.NewReader(b))
if err != nil {
return nil, fmt.Errorf("bad gzipped descriptor: %v", err)
}
out, err := ioutil.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("bad gzipped descriptor: %v", err)
}
return out, nil
}
func (s *serverReflectionServer) typeForName(name string) (reflect.Type, error) {
pt := proto.MessageType(name)
if pt == nil {
return nil, fmt.Errorf("unknown type: %q", name)
}
st := pt.Elem()
return st, nil
}
func (s *serverReflectionServer) fileDescContainingExtension(st reflect.Type, ext int32) (*dpb.FileDescriptorProto, error) {
m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(proto.Message)
if !ok {
return nil, fmt.Errorf("failed to create message from type: %v", st)
}
var extDesc *proto.ExtensionDesc
for id, desc := range proto.RegisteredExtensions(m) {
if id == ext {
extDesc = desc
break
}
}
if extDesc == nil {
return nil, fmt.Errorf("failed to find registered extension for extension number %v", ext)
}
return s.decodeFileDesc(proto.FileDescriptor(extDesc.Filename))
}
func (s *serverReflectionServer) allExtensionNumbersForType(st reflect.Type) ([]int32, error) {
m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(proto.Message)
if !ok {
return nil, fmt.Errorf("failed to create message from type: %v", st)
}
exts := proto.RegisteredExtensions(m)
out := make([]int32, 0, len(exts))
for id := range exts {
out = append(out, id)
}
return out, nil
}
// fileDescEncodingByFilename finds the file descriptor for given filename,
// does marshalling on it and returns the marshalled result.
func (s *serverReflectionServer) fileDescEncodingByFilename(name string) ([]byte, error) {
enc := proto.FileDescriptor(name)
if enc == nil {
return nil, fmt.Errorf("unknown file: %v", name)
}
fd, err := s.decodeFileDesc(enc)
if err != nil {
return nil, err
}
return proto.Marshal(fd)
}
// serviceMetadataForSymbol finds the metadata for name in s.serviceInfo.
// name should be a service name or a method name.
func (s *serverReflectionServer) serviceMetadataForSymbol(name string) (interface{}, error) {
if s.serviceInfo == nil {
s.serviceInfo = s.s.GetServiceInfo()
}
// Check if it's a service name.
if info, ok := s.serviceInfo[name]; ok {
return info.Metadata, nil
}
// Check if it's a method name.
pos := strings.LastIndex(name, ".")
// Not a valid method name.
if pos == -1 {
return nil, fmt.Errorf("unknown symbol: %v", name)
}
info, ok := s.serviceInfo[name[:pos]]
// Substring before last "." is not a service name.
if !ok {
return nil, fmt.Errorf("unknown symbol: %v", name)
}
// Search the method name in info.Methods.
var found bool
for _, m := range info.Methods {
if m.Name == name[pos+1:] {
found = true
break
}
}
if found {
return info.Metadata, nil
}
return nil, fmt.Errorf("unknown symbol: %v", name)
}
// parseMetadata finds the file descriptor bytes specified meta.
// For SupportPackageIsVersion4, m is the name of the proto file, we
// call proto.FileDescriptor to get the byte slice.
// For SupportPackageIsVersion3, m is a byte slice itself.
func parseMetadata(meta interface{}) ([]byte, bool) {
// Check if meta is the file name.
if fileNameForMeta, ok := meta.(string); ok {
return proto.FileDescriptor(fileNameForMeta), true
}
// Check if meta is the byte slice.
if enc, ok := meta.([]byte); ok {
return enc, true
}
return nil, false
}
// fileDescEncodingContainingSymbol finds the file descriptor containing the given symbol,
// does marshalling on it and returns the marshalled result.
// The given symbol can be a type, a service or a method.
func (s *serverReflectionServer) fileDescEncodingContainingSymbol(name string) ([]byte, error) {
var (
fd *dpb.FileDescriptorProto
)
// Check if it's a type name.
if st, err := s.typeForName(name); err == nil {
fd, err = s.fileDescForType(st)
if err != nil {
return nil, err
}
} else { // Check if it's a service name or a method name.
meta, err := s.serviceMetadataForSymbol(name)
// Metadata not found.
if err != nil {
return nil, err
}
// Metadata not valid.
enc, ok := parseMetadata(meta)
if !ok {
return nil, fmt.Errorf("invalid file descriptor for symbol: %v", name)
}
fd, err = s.decodeFileDesc(enc)
if err != nil {
return nil, err
}
}
return proto.Marshal(fd)
}
// fileDescEncodingContainingExtension finds the file descriptor containing given extension,
// does marshalling on it and returns the marshalled result.
func (s *serverReflectionServer) fileDescEncodingContainingExtension(typeName string, extNum int32) ([]byte, error) {
st, err := s.typeForName(typeName)
if err != nil {
return nil, err
}
fd, err := s.fileDescContainingExtension(st, extNum)
if err != nil {
return nil, err
}
return proto.Marshal(fd)
}
// allExtensionNumbersForTypeName returns all extension numbers for the given type.
func (s *serverReflectionServer) allExtensionNumbersForTypeName(name string) ([]int32, error) {
st, err := s.typeForName(name)
if err != nil {
return nil, err
}
extNums, err := s.allExtensionNumbersForType(st)
if err != nil {
return nil, err
}
return extNums, nil
}
// ServerReflectionInfo is the reflection service handler.
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
}
out := &rpb.ServerReflectionResponse{
ValidHost: in.Host,
OriginalRequest: in,
}
switch req := in.MessageRequest.(type) {
case *rpb.ServerReflectionRequest_FileByFilename:
b, err := s.fileDescEncodingByFilename(req.FileByFilename)
if err != nil {
out.MessageResponse = &rpb.ServerReflectionResponse_ErrorResponse{
ErrorResponse: &rpb.ErrorResponse{
ErrorCode: int32(codes.NotFound),
ErrorMessage: err.Error(),
},
}
} else {
out.MessageResponse = &rpb.ServerReflectionResponse_FileDescriptorResponse{
FileDescriptorResponse: &rpb.FileDescriptorResponse{FileDescriptorProto: [][]byte{b}},
}
}
case *rpb.ServerReflectionRequest_FileContainingSymbol:
b, err := s.fileDescEncodingContainingSymbol(req.FileContainingSymbol)
if err != nil {
out.MessageResponse = &rpb.ServerReflectionResponse_ErrorResponse{
ErrorResponse: &rpb.ErrorResponse{
ErrorCode: int32(codes.NotFound),
ErrorMessage: err.Error(),
},
}
} else {
out.MessageResponse = &rpb.ServerReflectionResponse_FileDescriptorResponse{
FileDescriptorResponse: &rpb.FileDescriptorResponse{FileDescriptorProto: [][]byte{b}},
}
}
case *rpb.ServerReflectionRequest_FileContainingExtension:
typeName := req.FileContainingExtension.ContainingType
extNum := req.FileContainingExtension.ExtensionNumber
b, err := s.fileDescEncodingContainingExtension(typeName, extNum)
if err != nil {
out.MessageResponse = &rpb.ServerReflectionResponse_ErrorResponse{
ErrorResponse: &rpb.ErrorResponse{
ErrorCode: int32(codes.NotFound),
ErrorMessage: err.Error(),
},
}
} else {
out.MessageResponse = &rpb.ServerReflectionResponse_FileDescriptorResponse{
FileDescriptorResponse: &rpb.FileDescriptorResponse{FileDescriptorProto: [][]byte{b}},
}
}
case *rpb.ServerReflectionRequest_AllExtensionNumbersOfType:
extNums, err := s.allExtensionNumbersForTypeName(req.AllExtensionNumbersOfType)
if err != nil {
out.MessageResponse = &rpb.ServerReflectionResponse_ErrorResponse{
ErrorResponse: &rpb.ErrorResponse{
ErrorCode: int32(codes.NotFound),
ErrorMessage: err.Error(),
},
}
} else {
out.MessageResponse = &rpb.ServerReflectionResponse_AllExtensionNumbersResponse{
AllExtensionNumbersResponse: &rpb.ExtensionNumberResponse{
BaseTypeName: req.AllExtensionNumbersOfType,
ExtensionNumber: extNums,
},
}
}
case *rpb.ServerReflectionRequest_ListServices:
if s.serviceInfo == nil {
s.serviceInfo = s.s.GetServiceInfo()
}
serviceResponses := make([]*rpb.ServiceResponse, 0, len(s.serviceInfo))
for n := range s.serviceInfo {
serviceResponses = append(serviceResponses, &rpb.ServiceResponse{
Name: n,
})
}
out.MessageResponse = &rpb.ServerReflectionResponse_ListServicesResponse{
ListServicesResponse: &rpb.ListServiceResponse{
Service: serviceResponses,
},
}
default:
return status.Errorf(codes.InvalidArgument, "invalid MessageRequest: %v", in.MessageRequest)
}
if err := stream.Send(out); err != nil {
return err
}
}
}

View File

@ -0,0 +1,520 @@
/*
*
* Copyright 2016 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
//go:generate protoc -I grpc_testing --go_out=plugins=grpc:grpc_testing/ grpc_testing/proto2.proto grpc_testing/proto2_ext.proto grpc_testing/proto2_ext2.proto grpc_testing/test.proto
// Note: grpc_testingv3/testv3.pb.go is not re-generated because it was
// intentionally generated by an older version of protoc-gen-go.
package reflection
import (
"fmt"
"net"
"reflect"
"sort"
"testing"
"github.com/golang/protobuf/proto"
dpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
"golang.org/x/net/context"
"google.golang.org/grpc"
rpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
pb "google.golang.org/grpc/reflection/grpc_testing"
pbv3 "google.golang.org/grpc/reflection/grpc_testingv3"
)
var (
s = &serverReflectionServer{}
// fileDescriptor of each test proto file.
fdTest *dpb.FileDescriptorProto
fdTestv3 *dpb.FileDescriptorProto
fdProto2 *dpb.FileDescriptorProto
fdProto2Ext *dpb.FileDescriptorProto
fdProto2Ext2 *dpb.FileDescriptorProto
// fileDescriptor marshalled.
fdTestByte []byte
fdTestv3Byte []byte
fdProto2Byte []byte
fdProto2ExtByte []byte
fdProto2Ext2Byte []byte
)
func loadFileDesc(filename string) (*dpb.FileDescriptorProto, []byte) {
enc := proto.FileDescriptor(filename)
if enc == nil {
panic(fmt.Sprintf("failed to find fd for file: %v", filename))
}
fd, err := s.decodeFileDesc(enc)
if err != nil {
panic(fmt.Sprintf("failed to decode enc: %v", err))
}
b, err := proto.Marshal(fd)
if err != nil {
panic(fmt.Sprintf("failed to marshal fd: %v", err))
}
return fd, b
}
func init() {
fdTest, fdTestByte = loadFileDesc("test.proto")
fdTestv3, fdTestv3Byte = loadFileDesc("testv3.proto")
fdProto2, fdProto2Byte = loadFileDesc("proto2.proto")
fdProto2Ext, fdProto2ExtByte = loadFileDesc("proto2_ext.proto")
fdProto2Ext2, fdProto2Ext2Byte = loadFileDesc("proto2_ext2.proto")
}
func TestFileDescForType(t *testing.T) {
for _, test := range []struct {
st reflect.Type
wantFd *dpb.FileDescriptorProto
}{
{reflect.TypeOf(pb.SearchResponse_Result{}), fdTest},
{reflect.TypeOf(pb.ToBeExtended{}), fdProto2},
} {
fd, err := s.fileDescForType(test.st)
if err != nil || !proto.Equal(fd, test.wantFd) {
t.Errorf("fileDescForType(%q) = %q, %v, want %q, <nil>", test.st, fd, err, test.wantFd)
}
}
}
func TestTypeForName(t *testing.T) {
for _, test := range []struct {
name string
want reflect.Type
}{
{"grpc.testing.SearchResponse", reflect.TypeOf(pb.SearchResponse{})},
} {
r, err := s.typeForName(test.name)
if err != nil || r != test.want {
t.Errorf("typeForName(%q) = %q, %v, want %q, <nil>", test.name, r, err, test.want)
}
}
}
func TestTypeForNameNotFound(t *testing.T) {
for _, test := range []string{
"grpc.testing.not_exiting",
} {
_, err := s.typeForName(test)
if err == nil {
t.Errorf("typeForName(%q) = _, %v, want _, <non-nil>", test, err)
}
}
}
func TestFileDescContainingExtension(t *testing.T) {
for _, test := range []struct {
st reflect.Type
extNum int32
want *dpb.FileDescriptorProto
}{
{reflect.TypeOf(pb.ToBeExtended{}), 13, fdProto2Ext},
{reflect.TypeOf(pb.ToBeExtended{}), 17, fdProto2Ext},
{reflect.TypeOf(pb.ToBeExtended{}), 19, fdProto2Ext},
{reflect.TypeOf(pb.ToBeExtended{}), 23, fdProto2Ext2},
{reflect.TypeOf(pb.ToBeExtended{}), 29, fdProto2Ext2},
} {
fd, err := s.fileDescContainingExtension(test.st, test.extNum)
if err != nil || !proto.Equal(fd, test.want) {
t.Errorf("fileDescContainingExtension(%q) = %q, %v, want %q, <nil>", test.st, fd, err, test.want)
}
}
}
// intArray is used to sort []int32
type intArray []int32
func (s intArray) Len() int { return len(s) }
func (s intArray) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s intArray) Less(i, j int) bool { return s[i] < s[j] }
func TestAllExtensionNumbersForType(t *testing.T) {
for _, test := range []struct {
st reflect.Type
want []int32
}{
{reflect.TypeOf(pb.ToBeExtended{}), []int32{13, 17, 19, 23, 29}},
} {
r, err := s.allExtensionNumbersForType(test.st)
sort.Sort(intArray(r))
if err != nil || !reflect.DeepEqual(r, test.want) {
t.Errorf("allExtensionNumbersForType(%q) = %v, %v, want %v, <nil>", test.st, r, err, test.want)
}
}
}
// Do end2end tests.
type server struct{}
func (s *server) Search(ctx context.Context, in *pb.SearchRequest) (*pb.SearchResponse, error) {
return &pb.SearchResponse{}, nil
}
func (s *server) StreamingSearch(stream pb.SearchService_StreamingSearchServer) error {
return nil
}
type serverV3 struct{}
func (s *serverV3) Search(ctx context.Context, in *pbv3.SearchRequestV3) (*pbv3.SearchResponseV3, error) {
return &pbv3.SearchResponseV3{}, nil
}
func (s *serverV3) StreamingSearch(stream pbv3.SearchServiceV3_StreamingSearchServer) error {
return nil
}
func TestReflectionEnd2end(t *testing.T) {
// Start server.
lis, err := net.Listen("tcp", "localhost:0")
if err != nil {
t.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer()
pb.RegisterSearchServiceServer(s, &server{})
pbv3.RegisterSearchServiceV3Server(s, &serverV3{})
// Register reflection service on s.
Register(s)
go s.Serve(lis)
// Create client.
conn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
if err != nil {
t.Fatalf("cannot connect to server: %v", err)
}
defer conn.Close()
c := rpb.NewServerReflectionClient(conn)
stream, err := c.ServerReflectionInfo(context.Background(), grpc.FailFast(false))
if err != nil {
t.Fatalf("cannot get ServerReflectionInfo: %v", err)
}
testFileByFilename(t, stream)
testFileByFilenameError(t, stream)
testFileContainingSymbol(t, stream)
testFileContainingSymbolError(t, stream)
testFileContainingExtension(t, stream)
testFileContainingExtensionError(t, stream)
testAllExtensionNumbersOfType(t, stream)
testAllExtensionNumbersOfTypeError(t, stream)
testListServices(t, stream)
s.Stop()
}
func testFileByFilename(t *testing.T, stream rpb.ServerReflection_ServerReflectionInfoClient) {
for _, test := range []struct {
filename string
want []byte
}{
{"test.proto", fdTestByte},
{"proto2.proto", fdProto2Byte},
{"proto2_ext.proto", fdProto2ExtByte},
} {
if err := stream.Send(&rpb.ServerReflectionRequest{
MessageRequest: &rpb.ServerReflectionRequest_FileByFilename{
FileByFilename: test.filename,
},
}); err != nil {
t.Fatalf("failed to send request: %v", err)
}
r, err := stream.Recv()
if err != nil {
// io.EOF is not ok.
t.Fatalf("failed to recv response: %v", err)
}
switch r.MessageResponse.(type) {
case *rpb.ServerReflectionResponse_FileDescriptorResponse:
if !reflect.DeepEqual(r.GetFileDescriptorResponse().FileDescriptorProto[0], test.want) {
t.Errorf("FileByFilename(%v)\nreceived: %q,\nwant: %q", test.filename, r.GetFileDescriptorResponse().FileDescriptorProto[0], test.want)
}
default:
t.Errorf("FileByFilename(%v) = %v, want type <ServerReflectionResponse_FileDescriptorResponse>", test.filename, r.MessageResponse)
}
}
}
func testFileByFilenameError(t *testing.T, stream rpb.ServerReflection_ServerReflectionInfoClient) {
for _, test := range []string{
"test.poto",
"proo2.proto",
"proto2_et.proto",
} {
if err := stream.Send(&rpb.ServerReflectionRequest{
MessageRequest: &rpb.ServerReflectionRequest_FileByFilename{
FileByFilename: test,
},
}); err != nil {
t.Fatalf("failed to send request: %v", err)
}
r, err := stream.Recv()
if err != nil {
// io.EOF is not ok.
t.Fatalf("failed to recv response: %v", err)
}
switch r.MessageResponse.(type) {
case *rpb.ServerReflectionResponse_ErrorResponse:
default:
t.Errorf("FileByFilename(%v) = %v, want type <ServerReflectionResponse_ErrorResponse>", test, r.MessageResponse)
}
}
}
func testFileContainingSymbol(t *testing.T, stream rpb.ServerReflection_ServerReflectionInfoClient) {
for _, test := range []struct {
symbol string
want []byte
}{
{"grpc.testing.SearchService", fdTestByte},
{"grpc.testing.SearchService.Search", fdTestByte},
{"grpc.testing.SearchService.StreamingSearch", fdTestByte},
{"grpc.testing.SearchResponse", fdTestByte},
{"grpc.testing.ToBeExtended", fdProto2Byte},
// Test support package v3.
{"grpc.testingv3.SearchServiceV3", fdTestv3Byte},
{"grpc.testingv3.SearchServiceV3.Search", fdTestv3Byte},
{"grpc.testingv3.SearchServiceV3.StreamingSearch", fdTestv3Byte},
{"grpc.testingv3.SearchResponseV3", fdTestv3Byte},
} {
if err := stream.Send(&rpb.ServerReflectionRequest{
MessageRequest: &rpb.ServerReflectionRequest_FileContainingSymbol{
FileContainingSymbol: test.symbol,
},
}); err != nil {
t.Fatalf("failed to send request: %v", err)
}
r, err := stream.Recv()
if err != nil {
// io.EOF is not ok.
t.Fatalf("failed to recv response: %v", err)
}
switch r.MessageResponse.(type) {
case *rpb.ServerReflectionResponse_FileDescriptorResponse:
if !reflect.DeepEqual(r.GetFileDescriptorResponse().FileDescriptorProto[0], test.want) {
t.Errorf("FileContainingSymbol(%v)\nreceived: %q,\nwant: %q", test.symbol, r.GetFileDescriptorResponse().FileDescriptorProto[0], test.want)
}
default:
t.Errorf("FileContainingSymbol(%v) = %v, want type <ServerReflectionResponse_FileDescriptorResponse>", test.symbol, r.MessageResponse)
}
}
}
func testFileContainingSymbolError(t *testing.T, stream rpb.ServerReflection_ServerReflectionInfoClient) {
for _, test := range []string{
"grpc.testing.SerchService",
"grpc.testing.SearchService.SearchE",
"grpc.tesing.SearchResponse",
"gpc.testing.ToBeExtended",
} {
if err := stream.Send(&rpb.ServerReflectionRequest{
MessageRequest: &rpb.ServerReflectionRequest_FileContainingSymbol{
FileContainingSymbol: test,
},
}); err != nil {
t.Fatalf("failed to send request: %v", err)
}
r, err := stream.Recv()
if err != nil {
// io.EOF is not ok.
t.Fatalf("failed to recv response: %v", err)
}
switch r.MessageResponse.(type) {
case *rpb.ServerReflectionResponse_ErrorResponse:
default:
t.Errorf("FileContainingSymbol(%v) = %v, want type <ServerReflectionResponse_ErrorResponse>", test, r.MessageResponse)
}
}
}
func testFileContainingExtension(t *testing.T, stream rpb.ServerReflection_ServerReflectionInfoClient) {
for _, test := range []struct {
typeName string
extNum int32
want []byte
}{
{"grpc.testing.ToBeExtended", 13, fdProto2ExtByte},
{"grpc.testing.ToBeExtended", 17, fdProto2ExtByte},
{"grpc.testing.ToBeExtended", 19, fdProto2ExtByte},
{"grpc.testing.ToBeExtended", 23, fdProto2Ext2Byte},
{"grpc.testing.ToBeExtended", 29, fdProto2Ext2Byte},
} {
if err := stream.Send(&rpb.ServerReflectionRequest{
MessageRequest: &rpb.ServerReflectionRequest_FileContainingExtension{
FileContainingExtension: &rpb.ExtensionRequest{
ContainingType: test.typeName,
ExtensionNumber: test.extNum,
},
},
}); err != nil {
t.Fatalf("failed to send request: %v", err)
}
r, err := stream.Recv()
if err != nil {
// io.EOF is not ok.
t.Fatalf("failed to recv response: %v", err)
}
switch r.MessageResponse.(type) {
case *rpb.ServerReflectionResponse_FileDescriptorResponse:
if !reflect.DeepEqual(r.GetFileDescriptorResponse().FileDescriptorProto[0], test.want) {
t.Errorf("FileContainingExtension(%v, %v)\nreceived: %q,\nwant: %q", test.typeName, test.extNum, r.GetFileDescriptorResponse().FileDescriptorProto[0], test.want)
}
default:
t.Errorf("FileContainingExtension(%v, %v) = %v, want type <ServerReflectionResponse_FileDescriptorResponse>", test.typeName, test.extNum, r.MessageResponse)
}
}
}
func testFileContainingExtensionError(t *testing.T, stream rpb.ServerReflection_ServerReflectionInfoClient) {
for _, test := range []struct {
typeName string
extNum int32
}{
{"grpc.testing.ToBExtended", 17},
{"grpc.testing.ToBeExtended", 15},
} {
if err := stream.Send(&rpb.ServerReflectionRequest{
MessageRequest: &rpb.ServerReflectionRequest_FileContainingExtension{
FileContainingExtension: &rpb.ExtensionRequest{
ContainingType: test.typeName,
ExtensionNumber: test.extNum,
},
},
}); err != nil {
t.Fatalf("failed to send request: %v", err)
}
r, err := stream.Recv()
if err != nil {
// io.EOF is not ok.
t.Fatalf("failed to recv response: %v", err)
}
switch r.MessageResponse.(type) {
case *rpb.ServerReflectionResponse_ErrorResponse:
default:
t.Errorf("FileContainingExtension(%v, %v) = %v, want type <ServerReflectionResponse_FileDescriptorResponse>", test.typeName, test.extNum, r.MessageResponse)
}
}
}
func testAllExtensionNumbersOfType(t *testing.T, stream rpb.ServerReflection_ServerReflectionInfoClient) {
for _, test := range []struct {
typeName string
want []int32
}{
{"grpc.testing.ToBeExtended", []int32{13, 17, 19, 23, 29}},
} {
if err := stream.Send(&rpb.ServerReflectionRequest{
MessageRequest: &rpb.ServerReflectionRequest_AllExtensionNumbersOfType{
AllExtensionNumbersOfType: test.typeName,
},
}); err != nil {
t.Fatalf("failed to send request: %v", err)
}
r, err := stream.Recv()
if err != nil {
// io.EOF is not ok.
t.Fatalf("failed to recv response: %v", err)
}
switch r.MessageResponse.(type) {
case *rpb.ServerReflectionResponse_AllExtensionNumbersResponse:
extNum := r.GetAllExtensionNumbersResponse().ExtensionNumber
sort.Sort(intArray(extNum))
if r.GetAllExtensionNumbersResponse().BaseTypeName != test.typeName ||
!reflect.DeepEqual(extNum, test.want) {
t.Errorf("AllExtensionNumbersOfType(%v)\nreceived: %v,\nwant: {%q %v}", r.GetAllExtensionNumbersResponse(), test.typeName, test.typeName, test.want)
}
default:
t.Errorf("AllExtensionNumbersOfType(%v) = %v, want type <ServerReflectionResponse_AllExtensionNumbersResponse>", test.typeName, r.MessageResponse)
}
}
}
func testAllExtensionNumbersOfTypeError(t *testing.T, stream rpb.ServerReflection_ServerReflectionInfoClient) {
for _, test := range []string{
"grpc.testing.ToBeExtendedE",
} {
if err := stream.Send(&rpb.ServerReflectionRequest{
MessageRequest: &rpb.ServerReflectionRequest_AllExtensionNumbersOfType{
AllExtensionNumbersOfType: test,
},
}); err != nil {
t.Fatalf("failed to send request: %v", err)
}
r, err := stream.Recv()
if err != nil {
// io.EOF is not ok.
t.Fatalf("failed to recv response: %v", err)
}
switch r.MessageResponse.(type) {
case *rpb.ServerReflectionResponse_ErrorResponse:
default:
t.Errorf("AllExtensionNumbersOfType(%v) = %v, want type <ServerReflectionResponse_ErrorResponse>", test, r.MessageResponse)
}
}
}
func testListServices(t *testing.T, stream rpb.ServerReflection_ServerReflectionInfoClient) {
if err := stream.Send(&rpb.ServerReflectionRequest{
MessageRequest: &rpb.ServerReflectionRequest_ListServices{},
}); err != nil {
t.Fatalf("failed to send request: %v", err)
}
r, err := stream.Recv()
if err != nil {
// io.EOF is not ok.
t.Fatalf("failed to recv response: %v", err)
}
switch r.MessageResponse.(type) {
case *rpb.ServerReflectionResponse_ListServicesResponse:
services := r.GetListServicesResponse().Service
want := []string{
"grpc.testingv3.SearchServiceV3",
"grpc.testing.SearchService",
"grpc.reflection.v1alpha.ServerReflection",
}
// Compare service names in response with want.
if len(services) != len(want) {
t.Errorf("= %v, want service names: %v", services, want)
}
m := make(map[string]int)
for _, e := range services {
m[e.Name]++
}
for _, e := range want {
if m[e] > 0 {
m[e]--
continue
}
t.Errorf("ListService\nreceived: %v,\nwant: %q", services, want)
}
default:
t.Errorf("ListServices = %v, want type <ServerReflectionResponse_ListServicesResponse>", r.MessageResponse)
}
}