diff --git a/internal/server/option.go b/internal/server/option.go index b540f03ce4..c9382ffe66 100644 --- a/internal/server/option.go +++ b/internal/server/option.go @@ -100,6 +100,9 @@ type Options struct { RefuseTrafficWithoutServiceName bool EnableContextTimeout bool + + // Reflection + EnableGrpcReflection bool } type Limit struct { diff --git a/pkg/reflection/grpc/adapt.go b/pkg/reflection/grpc/adapt.go new file mode 100644 index 0000000000..1aa3a5acd5 --- /dev/null +++ b/pkg/reflection/grpc/adapt.go @@ -0,0 +1,53 @@ +/* + * Copyright 2024 CloudWeGo 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. + */ + +package grpc + +import ( + "github.com/cloudwego/kitex/pkg/reflection/grpc/handler" + v1 "github.com/cloudwego/kitex/pkg/reflection/grpc/reflection/v1" + "github.com/cloudwego/kitex/pkg/reflection/grpc/reflection/v1alpha" +) + +// asV1Alpha returns an implementation of the v1alpha version of the reflection +// interface that delegates all calls to the given v1 version. +func asV1Alpha(svr v1.ServerReflection) v1alpha.ServerReflection { + return v1AlphaServerImpl{svr: svr} +} + +type v1AlphaServerImpl struct { + svr v1.ServerReflection +} + +func (s v1AlphaServerImpl) ServerReflectionInfo(stream v1alpha.ServerReflection_ServerReflectionInfoServer) error { + return s.svr.ServerReflectionInfo(v1AlphaServerStreamAdapter{stream}) +} + +type v1AlphaServerStreamAdapter struct { + v1alpha.ServerReflection_ServerReflectionInfoServer +} + +func (s v1AlphaServerStreamAdapter) Send(response *v1.ServerReflectionResponse) error { + return s.ServerReflection_ServerReflectionInfoServer.Send(handler.V1ToV1AlphaResponse(response)) +} + +func (s v1AlphaServerStreamAdapter) Recv() (*v1.ServerReflectionRequest, error) { + resp, err := s.ServerReflection_ServerReflectionInfoServer.Recv() + if err != nil { + return nil, err + } + return handler.V1AlphaToV1Request(resp), nil +} diff --git a/pkg/reflection/grpc/grpc.go b/pkg/reflection/grpc/grpc.go new file mode 100644 index 0000000000..3e1be76153 --- /dev/null +++ b/pkg/reflection/grpc/grpc.go @@ -0,0 +1,40 @@ +/* + * Copyright 2024 CloudWeGo 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. + */ + +package grpc + +import ( + "github.com/cloudwego/kitex/pkg/reflection/grpc/handler" + "github.com/cloudwego/kitex/pkg/reflection/grpc/reflection/v1" + reflection_v1_service "github.com/cloudwego/kitex/pkg/reflection/grpc/reflection/v1/serverreflection" + "github.com/cloudwego/kitex/pkg/reflection/grpc/reflection/v1alpha" + reflection_v1alpha_service "github.com/cloudwego/kitex/pkg/reflection/grpc/reflection/v1alpha/serverreflection" + "github.com/cloudwego/kitex/pkg/serviceinfo" + "google.golang.org/protobuf/reflect/protoregistry" +) + +var ( + NewV1ServiceInfo = reflection_v1_service.NewServiceInfo + NewV1AlphaServiceInfo = reflection_v1alpha_service.NewServiceInfo +) + +func NewV1Handler(svcs map[string]*serviceinfo.ServiceInfo) v1.ServerReflection { + return handler.NewServerReflection(svcs, protoregistry.GlobalFiles, protoregistry.GlobalTypes) +} + +func NewV1alphaHandler(svcs map[string]*serviceinfo.ServiceInfo) v1alpha.ServerReflection { + return asV1Alpha(NewV1Handler(svcs)) +} diff --git a/pkg/reflection/grpc/handler/handler.go b/pkg/reflection/grpc/handler/handler.go new file mode 100644 index 0000000000..15328bb4a1 --- /dev/null +++ b/pkg/reflection/grpc/handler/handler.go @@ -0,0 +1,429 @@ +/* + * Copyright 2024 CloudWeGo 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. + */ + +package handler + +import ( + reflection_v1 "github.com/cloudwego/kitex/pkg/reflection/grpc/reflection/v1" + reflection_v1alpha "github.com/cloudwego/kitex/pkg/reflection/grpc/reflection/v1alpha" + "github.com/cloudwego/kitex/pkg/remote/trans/nphttp2/codes" + "github.com/cloudwego/kitex/pkg/remote/trans/nphttp2/status" + "github.com/cloudwego/kitex/pkg/serviceinfo" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protodesc" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + "io" + "sort" +) + +// ExtensionResolver is the interface used to query details about extensions. +// This interface is satisfied by protoregistry.GlobalTypes. +type ExtensionResolver interface { + protoregistry.ExtensionTypeResolver + RangeExtensionsByMessage(message protoreflect.FullName, f func(protoreflect.ExtensionType) bool) +} + +// serverReflectionImpl implements ServerReflection interface. +type serverReflectionImpl struct { + svcs map[string]*serviceinfo.ServiceInfo + DescResolver protodesc.Resolver + ExtResolver ExtensionResolver +} + +func NewServerReflection(svcs map[string]*serviceinfo.ServiceInfo, descRes protodesc.Resolver, extRes ExtensionResolver) reflection_v1.ServerReflection { + return &serverReflectionImpl{ + svcs: svcs, + DescResolver: descRes, + ExtResolver: extRes, + } +} + +// FileDescWithDependencies returns a slice of serialized fileDescriptors in +// wire format ([]byte). The fileDescriptors will include fd and all the +// transitive dependencies of fd with names not in sentFileDescriptors. +func (s *serverReflectionImpl) FileDescWithDependencies(fd protoreflect.FileDescriptor, sentFileDescriptors map[string]bool) ([][]byte, error) { + if fd.IsPlaceholder() { + // If the given root file is a placeholder, treat it + // as missing instead of serializing it. + return nil, protoregistry.NotFound + } + var r [][]byte + queue := []protoreflect.FileDescriptor{fd} + for len(queue) > 0 { + currentfd := queue[0] + queue = queue[1:] + if currentfd.IsPlaceholder() { + // Skip any missing files in the dependency graph. + continue + } + if sent := sentFileDescriptors[currentfd.Path()]; len(r) == 0 || !sent { + sentFileDescriptors[currentfd.Path()] = true + fdProto := protodesc.ToFileDescriptorProto(currentfd) + currentfdEncoded, err := proto.Marshal(fdProto) + if err != nil { + return nil, err + } + r = append(r, currentfdEncoded) + } + for i := 0; i < currentfd.Imports().Len(); i++ { + queue = append(queue, currentfd.Imports().Get(i)) + } + } + return r, nil +} + +// FileDescEncodingContainingSymbol finds the file descriptor containing the +// given symbol, finds all of its previously unsent transitive dependencies, +// does marshalling on them, and returns the marshalled result. The given symbol +// can be a type, a service or a method. +func (s *serverReflectionImpl) FileDescEncodingContainingSymbol(name string, fdMap map[string]bool) ([][]byte, error) { + d, err := s.DescResolver.FindDescriptorByName(protoreflect.FullName(name)) + if err != nil { + return nil, err + } + return s.FileDescWithDependencies(d.ParentFile(), fdMap) +} + +// FileDescEncodingContainingExtension finds the file descriptor containing +// given extension, finds all of its previously unsent transitive dependencies, +// does marshalling on them, and returns the marshalled result. +func (s *serverReflectionImpl) FileDescEncodingContainingExtension(typeName string, extNum int32, sentFileDescriptors map[string]bool) ([][]byte, error) { + xt, err := s.ExtResolver.FindExtensionByNumber(protoreflect.FullName(typeName), protoreflect.FieldNumber(extNum)) + if err != nil { + return nil, err + } + return s.FileDescWithDependencies(xt.TypeDescriptor().ParentFile(), sentFileDescriptors) +} + +// AllExtensionNumbersForTypeName returns all extension numbers for the given type. +func (s *serverReflectionImpl) AllExtensionNumbersForTypeName(name string) ([]int32, error) { + var numbers []int32 + s.ExtResolver.RangeExtensionsByMessage(protoreflect.FullName(name), func(xt protoreflect.ExtensionType) bool { + numbers = append(numbers, int32(xt.TypeDescriptor().Number())) + return true + }) + sort.Slice(numbers, func(i, j int) bool { + return numbers[i] < numbers[j] + }) + if len(numbers) == 0 { + // maybe return an error if given type name is not known + if _, err := s.DescResolver.FindDescriptorByName(protoreflect.FullName(name)); err != nil { + return nil, err + } + } + return numbers, nil +} + +// listServices returns the names of services this server exposes. +func (s *serverReflectionImpl) listServices() []*reflection_v1.ServiceResponse { + res := make([]*reflection_v1.ServiceResponse, 0, len(s.svcs)) + for name := range s.svcs { + res = append(res, &reflection_v1.ServiceResponse{Name: name}) + } + sort.Slice(res, func(i, j int) bool { + return res[i].Name < res[j].Name + }) + return res +} + +// ServerReflectionInfo is the reflection service handler. +func (s *serverReflectionImpl) ServerReflectionInfo(stream reflection_v1.ServerReflection_ServerReflectionInfoServer) error { + fdMap := make(map[string]bool) + for { + req, err := stream.Recv() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + + resp := &reflection_v1.ServerReflectionResponse{ + ValidHost: req.Host, + OriginalRequest: req, + } + switch msg := req.MessageRequest.(type) { + case *reflection_v1.ServerReflectionRequest_FileByFilename: + var buf [][]byte + fd, err := s.DescResolver.FindFileByPath(msg.FileByFilename) + if err == nil { + buf, err = s.FileDescWithDependencies(fd, fdMap) + } + if err != nil { + resp.MessageResponse = &reflection_v1.ServerReflectionResponse_ErrorResponse{ + ErrorResponse: &reflection_v1.ErrorResponse{ + ErrorCode: int32(codes.NotFound), + ErrorMessage: err.Error(), + }, + } + } else { + resp.MessageResponse = &reflection_v1.ServerReflectionResponse_FileDescriptorResponse{ + FileDescriptorResponse: &reflection_v1.FileDescriptorResponse{ + FileDescriptorProto: buf, + }, + } + } + case *reflection_v1.ServerReflectionRequest_FileContainingSymbol: + b, err := s.FileDescEncodingContainingSymbol(msg.FileContainingSymbol, fdMap) + if err != nil { + resp.MessageResponse = &reflection_v1.ServerReflectionResponse_ErrorResponse{ + ErrorResponse: &reflection_v1.ErrorResponse{ + ErrorCode: int32(codes.NotFound), + ErrorMessage: err.Error(), + }, + } + } else { + resp.MessageResponse = &reflection_v1.ServerReflectionResponse_FileDescriptorResponse{ + FileDescriptorResponse: &reflection_v1.FileDescriptorResponse{FileDescriptorProto: b}, + } + } + case *reflection_v1.ServerReflectionRequest_FileContainingExtension: + typeName := msg.FileContainingExtension.ContainingType + extNum := msg.FileContainingExtension.ExtensionNumber + b, err := s.FileDescEncodingContainingExtension(typeName, extNum, fdMap) + if err != nil { + resp.MessageResponse = &reflection_v1.ServerReflectionResponse_ErrorResponse{ + ErrorResponse: &reflection_v1.ErrorResponse{ + ErrorCode: int32(codes.NotFound), + ErrorMessage: err.Error(), + }, + } + } else { + resp.MessageResponse = &reflection_v1.ServerReflectionResponse_FileDescriptorResponse{ + FileDescriptorResponse: &reflection_v1.FileDescriptorResponse{FileDescriptorProto: b}, + } + } + case *reflection_v1.ServerReflectionRequest_AllExtensionNumbersOfType: + extNums, err := s.AllExtensionNumbersForTypeName(msg.AllExtensionNumbersOfType) + if err != nil { + resp.MessageResponse = &reflection_v1.ServerReflectionResponse_ErrorResponse{ + ErrorResponse: &reflection_v1.ErrorResponse{ + ErrorCode: int32(codes.NotFound), + ErrorMessage: err.Error(), + }, + } + } else { + resp.MessageResponse = &reflection_v1.ServerReflectionResponse_AllExtensionNumbersResponse{ + AllExtensionNumbersResponse: &reflection_v1.ExtensionNumberResponse{ + BaseTypeName: msg.AllExtensionNumbersOfType, + ExtensionNumber: extNums, + }, + } + } + case *reflection_v1.ServerReflectionRequest_ListServices: + resp.MessageResponse = &reflection_v1.ServerReflectionResponse_ListServicesResponse{ + ListServicesResponse: &reflection_v1.ListServiceResponse{ + Service: s.listServices(), + }, + } + default: + return status.Errorf(codes.InvalidArgument, "invalid MessageRequest: %v", req.MessageRequest) + } + + if err := stream.Send(resp); err != nil { + return err + } + } +} + +// V1ToV1AlphaResponse converts a v1 ServerReflectionResponse to a v1alpha. +func V1ToV1AlphaResponse(v1 *reflection_v1.ServerReflectionResponse) *reflection_v1alpha.ServerReflectionResponse { + var v1alpha reflection_v1alpha.ServerReflectionResponse + v1alpha.ValidHost = v1.ValidHost + if v1.OriginalRequest != nil { + v1alpha.OriginalRequest = V1ToV1AlphaRequest(v1.OriginalRequest) + } + switch mr := v1.MessageResponse.(type) { + case *reflection_v1.ServerReflectionResponse_FileDescriptorResponse: + if mr != nil { + v1alpha.MessageResponse = &reflection_v1alpha.ServerReflectionResponse_FileDescriptorResponse{ + FileDescriptorResponse: &reflection_v1alpha.FileDescriptorResponse{ + FileDescriptorProto: mr.FileDescriptorResponse.GetFileDescriptorProto(), + }, + } + } + case *reflection_v1.ServerReflectionResponse_AllExtensionNumbersResponse: + if mr != nil { + v1alpha.MessageResponse = &reflection_v1alpha.ServerReflectionResponse_AllExtensionNumbersResponse{ + AllExtensionNumbersResponse: &reflection_v1alpha.ExtensionNumberResponse{ + BaseTypeName: mr.AllExtensionNumbersResponse.GetBaseTypeName(), + ExtensionNumber: mr.AllExtensionNumbersResponse.GetExtensionNumber(), + }, + } + } + case *reflection_v1.ServerReflectionResponse_ListServicesResponse: + if mr != nil { + svcs := make([]*reflection_v1alpha.ServiceResponse, len(mr.ListServicesResponse.GetService())) + for i, svc := range mr.ListServicesResponse.GetService() { + svcs[i] = &reflection_v1alpha.ServiceResponse{ + Name: svc.GetName(), + } + } + v1alpha.MessageResponse = &reflection_v1alpha.ServerReflectionResponse_ListServicesResponse{ + ListServicesResponse: &reflection_v1alpha.ListServiceResponse{ + Service: svcs, + }, + } + } + case *reflection_v1.ServerReflectionResponse_ErrorResponse: + if mr != nil { + v1alpha.MessageResponse = &reflection_v1alpha.ServerReflectionResponse_ErrorResponse{ + ErrorResponse: &reflection_v1alpha.ErrorResponse{ + ErrorCode: mr.ErrorResponse.GetErrorCode(), + ErrorMessage: mr.ErrorResponse.GetErrorMessage(), + }, + } + } + default: + // no value set + } + return &v1alpha +} + +// V1AlphaToV1Request converts a v1alpha ServerReflectionRequest to a v1. +func V1AlphaToV1Request(v1alpha *reflection_v1alpha.ServerReflectionRequest) *reflection_v1.ServerReflectionRequest { + var v1 reflection_v1.ServerReflectionRequest + v1.Host = v1alpha.Host + switch mr := v1alpha.MessageRequest.(type) { + case *reflection_v1alpha.ServerReflectionRequest_FileByFilename: + v1.MessageRequest = &reflection_v1.ServerReflectionRequest_FileByFilename{ + FileByFilename: mr.FileByFilename, + } + case *reflection_v1alpha.ServerReflectionRequest_FileContainingSymbol: + v1.MessageRequest = &reflection_v1.ServerReflectionRequest_FileContainingSymbol{ + FileContainingSymbol: mr.FileContainingSymbol, + } + case *reflection_v1alpha.ServerReflectionRequest_FileContainingExtension: + if mr.FileContainingExtension != nil { + v1.MessageRequest = &reflection_v1.ServerReflectionRequest_FileContainingExtension{ + FileContainingExtension: &reflection_v1.ExtensionRequest{ + ContainingType: mr.FileContainingExtension.GetContainingType(), + ExtensionNumber: mr.FileContainingExtension.GetExtensionNumber(), + }, + } + } + case *reflection_v1alpha.ServerReflectionRequest_AllExtensionNumbersOfType: + v1.MessageRequest = &reflection_v1.ServerReflectionRequest_AllExtensionNumbersOfType{ + AllExtensionNumbersOfType: mr.AllExtensionNumbersOfType, + } + case *reflection_v1alpha.ServerReflectionRequest_ListServices: + v1.MessageRequest = &reflection_v1.ServerReflectionRequest_ListServices{ + ListServices: mr.ListServices, + } + default: + // no value set + } + return &v1 +} + +// V1ToV1AlphaRequest converts a v1 ServerReflectionRequest to a v1alpha. +func V1ToV1AlphaRequest(v1 *reflection_v1.ServerReflectionRequest) *reflection_v1alpha.ServerReflectionRequest { + var v1alpha reflection_v1alpha.ServerReflectionRequest + v1alpha.Host = v1.Host + switch mr := v1.MessageRequest.(type) { + case *reflection_v1.ServerReflectionRequest_FileByFilename: + if mr != nil { + v1alpha.MessageRequest = &reflection_v1alpha.ServerReflectionRequest_FileByFilename{ + FileByFilename: mr.FileByFilename, + } + } + case *reflection_v1.ServerReflectionRequest_FileContainingSymbol: + if mr != nil { + v1alpha.MessageRequest = &reflection_v1alpha.ServerReflectionRequest_FileContainingSymbol{ + FileContainingSymbol: mr.FileContainingSymbol, + } + } + case *reflection_v1.ServerReflectionRequest_FileContainingExtension: + if mr != nil { + v1alpha.MessageRequest = &reflection_v1alpha.ServerReflectionRequest_FileContainingExtension{ + FileContainingExtension: &reflection_v1alpha.ExtensionRequest{ + ContainingType: mr.FileContainingExtension.GetContainingType(), + ExtensionNumber: mr.FileContainingExtension.GetExtensionNumber(), + }, + } + } + case *reflection_v1.ServerReflectionRequest_AllExtensionNumbersOfType: + if mr != nil { + v1alpha.MessageRequest = &reflection_v1alpha.ServerReflectionRequest_AllExtensionNumbersOfType{ + AllExtensionNumbersOfType: mr.AllExtensionNumbersOfType, + } + } + case *reflection_v1.ServerReflectionRequest_ListServices: + if mr != nil { + v1alpha.MessageRequest = &reflection_v1alpha.ServerReflectionRequest_ListServices{ + ListServices: mr.ListServices, + } + } + default: + // no value set + } + return &v1alpha +} + +// V1AlphaToV1Response converts a v1alpha ServerReflectionResponse to a v1. +func V1AlphaToV1Response(v1alpha *reflection_v1alpha.ServerReflectionResponse) *reflection_v1.ServerReflectionResponse { + var v1 reflection_v1.ServerReflectionResponse + v1.ValidHost = v1alpha.ValidHost + if v1alpha.OriginalRequest != nil { + v1.OriginalRequest = V1AlphaToV1Request(v1alpha.OriginalRequest) + } + switch mr := v1alpha.MessageResponse.(type) { + case *reflection_v1alpha.ServerReflectionResponse_FileDescriptorResponse: + if mr != nil { + v1.MessageResponse = &reflection_v1.ServerReflectionResponse_FileDescriptorResponse{ + FileDescriptorResponse: &reflection_v1.FileDescriptorResponse{ + FileDescriptorProto: mr.FileDescriptorResponse.GetFileDescriptorProto(), + }, + } + } + case *reflection_v1alpha.ServerReflectionResponse_AllExtensionNumbersResponse: + if mr != nil { + v1.MessageResponse = &reflection_v1.ServerReflectionResponse_AllExtensionNumbersResponse{ + AllExtensionNumbersResponse: &reflection_v1.ExtensionNumberResponse{ + BaseTypeName: mr.AllExtensionNumbersResponse.GetBaseTypeName(), + ExtensionNumber: mr.AllExtensionNumbersResponse.GetExtensionNumber(), + }, + } + } + case *reflection_v1alpha.ServerReflectionResponse_ListServicesResponse: + if mr != nil { + svcs := make([]*reflection_v1.ServiceResponse, len(mr.ListServicesResponse.GetService())) + for i, svc := range mr.ListServicesResponse.GetService() { + svcs[i] = &reflection_v1.ServiceResponse{ + Name: svc.GetName(), + } + } + v1.MessageResponse = &reflection_v1.ServerReflectionResponse_ListServicesResponse{ + ListServicesResponse: &reflection_v1.ListServiceResponse{ + Service: svcs, + }, + } + } + case *reflection_v1alpha.ServerReflectionResponse_ErrorResponse: + if mr != nil { + v1.MessageResponse = &reflection_v1.ServerReflectionResponse_ErrorResponse{ + ErrorResponse: &reflection_v1.ErrorResponse{ + ErrorCode: mr.ErrorResponse.GetErrorCode(), + ErrorMessage: mr.ErrorResponse.GetErrorMessage(), + }, + } + } + default: + // no value set + } + return &v1 +} diff --git a/pkg/reflection/grpc/reflection/v1/reflection.pb.fast.go b/pkg/reflection/grpc/reflection/v1/reflection.pb.fast.go new file mode 100644 index 0000000000..4282d8f009 --- /dev/null +++ b/pkg/reflection/grpc/reflection/v1/reflection.pb.fast.go @@ -0,0 +1,979 @@ +/* + * Copyright 2024 CloudWeGo 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. + */ + +// Code generated by Fastpb v0.0.2. DO NOT EDIT. + +package v1 + +import ( + fmt "fmt" + fastpb "github.com/cloudwego/fastpb" +) + +var ( + _ = fmt.Errorf + _ = fastpb.Skip +) + +func (x *ServerReflectionRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 3: + offset, err = x.fastReadField3(buf, _type) + if err != nil { + goto ReadFieldError + } + case 4: + offset, err = x.fastReadField4(buf, _type) + if err != nil { + goto ReadFieldError + } + case 5: + offset, err = x.fastReadField5(buf, _type) + if err != nil { + goto ReadFieldError + } + case 6: + offset, err = x.fastReadField6(buf, _type) + if err != nil { + goto ReadFieldError + } + case 7: + offset, err = x.fastReadField7(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ServerReflectionRequest[number], err) +} + +func (x *ServerReflectionRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Host, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ServerReflectionRequest) fastReadField3(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionRequest_FileByFilename + x.MessageRequest = &ov + ov.FileByFilename, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ServerReflectionRequest) fastReadField4(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionRequest_FileContainingSymbol + x.MessageRequest = &ov + ov.FileContainingSymbol, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ServerReflectionRequest) fastReadField5(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionRequest_FileContainingExtension + x.MessageRequest = &ov + var v ExtensionRequest + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + ov.FileContainingExtension = &v + return offset, nil +} + +func (x *ServerReflectionRequest) fastReadField6(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionRequest_AllExtensionNumbersOfType + x.MessageRequest = &ov + ov.AllExtensionNumbersOfType, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ServerReflectionRequest) fastReadField7(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionRequest_ListServices + x.MessageRequest = &ov + ov.ListServices, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ExtensionRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 2: + offset, err = x.fastReadField2(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ExtensionRequest[number], err) +} + +func (x *ExtensionRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.ContainingType, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ExtensionRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { + x.ExtensionNumber, offset, err = fastpb.ReadInt32(buf, _type) + return offset, err +} + +func (x *ServerReflectionResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 2: + offset, err = x.fastReadField2(buf, _type) + if err != nil { + goto ReadFieldError + } + case 4: + offset, err = x.fastReadField4(buf, _type) + if err != nil { + goto ReadFieldError + } + case 5: + offset, err = x.fastReadField5(buf, _type) + if err != nil { + goto ReadFieldError + } + case 6: + offset, err = x.fastReadField6(buf, _type) + if err != nil { + goto ReadFieldError + } + case 7: + offset, err = x.fastReadField7(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ServerReflectionResponse[number], err) +} + +func (x *ServerReflectionResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.ValidHost, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ServerReflectionResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { + var v ServerReflectionRequest + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + x.OriginalRequest = &v + return offset, nil +} + +func (x *ServerReflectionResponse) fastReadField4(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionResponse_FileDescriptorResponse + x.MessageResponse = &ov + var v FileDescriptorResponse + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + ov.FileDescriptorResponse = &v + return offset, nil +} + +func (x *ServerReflectionResponse) fastReadField5(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionResponse_AllExtensionNumbersResponse + x.MessageResponse = &ov + var v ExtensionNumberResponse + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + ov.AllExtensionNumbersResponse = &v + return offset, nil +} + +func (x *ServerReflectionResponse) fastReadField6(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionResponse_ListServicesResponse + x.MessageResponse = &ov + var v ListServiceResponse + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + ov.ListServicesResponse = &v + return offset, nil +} + +func (x *ServerReflectionResponse) fastReadField7(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionResponse_ErrorResponse + x.MessageResponse = &ov + var v ErrorResponse + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + ov.ErrorResponse = &v + return offset, nil +} + +func (x *FileDescriptorResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_FileDescriptorResponse[number], err) +} + +func (x *FileDescriptorResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { + var v []byte + v, offset, err = fastpb.ReadBytes(buf, _type) + if err != nil { + return offset, err + } + x.FileDescriptorProto = append(x.FileDescriptorProto, v) + return offset, err +} + +func (x *ExtensionNumberResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 2: + offset, err = x.fastReadField2(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ExtensionNumberResponse[number], err) +} + +func (x *ExtensionNumberResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.BaseTypeName, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ExtensionNumberResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { + offset, err = fastpb.ReadList(buf, _type, + func(buf []byte, _type int8) (n int, err error) { + var v int32 + v, offset, err = fastpb.ReadInt32(buf, _type) + if err != nil { + return offset, err + } + x.ExtensionNumber = append(x.ExtensionNumber, v) + return offset, err + }) + return offset, err +} + +func (x *ListServiceResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ListServiceResponse[number], err) +} + +func (x *ListServiceResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { + var v ServiceResponse + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + x.Service = append(x.Service, &v) + return offset, nil +} + +func (x *ServiceResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ServiceResponse[number], err) +} + +func (x *ServiceResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Name, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ErrorResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 2: + offset, err = x.fastReadField2(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ErrorResponse[number], err) +} + +func (x *ErrorResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.ErrorCode, offset, err = fastpb.ReadInt32(buf, _type) + return offset, err +} + +func (x *ErrorResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { + x.ErrorMessage, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ServerReflectionRequest) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField3(buf[offset:]) + offset += x.fastWriteField4(buf[offset:]) + offset += x.fastWriteField5(buf[offset:]) + offset += x.fastWriteField6(buf[offset:]) + offset += x.fastWriteField7(buf[offset:]) + return offset +} + +func (x *ServerReflectionRequest) fastWriteField1(buf []byte) (offset int) { + if x.Host == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetHost()) + return offset +} + +func (x *ServerReflectionRequest) fastWriteField3(buf []byte) (offset int) { + if x.GetFileByFilename() == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 3, x.GetFileByFilename()) + return offset +} + +func (x *ServerReflectionRequest) fastWriteField4(buf []byte) (offset int) { + if x.GetFileContainingSymbol() == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 4, x.GetFileContainingSymbol()) + return offset +} + +func (x *ServerReflectionRequest) fastWriteField5(buf []byte) (offset int) { + if x.GetFileContainingExtension() == nil { + return offset + } + offset += fastpb.WriteMessage(buf[offset:], 5, x.GetFileContainingExtension()) + return offset +} + +func (x *ServerReflectionRequest) fastWriteField6(buf []byte) (offset int) { + if x.GetAllExtensionNumbersOfType() == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 6, x.GetAllExtensionNumbersOfType()) + return offset +} + +func (x *ServerReflectionRequest) fastWriteField7(buf []byte) (offset int) { + if x.GetListServices() == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 7, x.GetListServices()) + return offset +} + +func (x *ExtensionRequest) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField2(buf[offset:]) + return offset +} + +func (x *ExtensionRequest) fastWriteField1(buf []byte) (offset int) { + if x.ContainingType == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetContainingType()) + return offset +} + +func (x *ExtensionRequest) fastWriteField2(buf []byte) (offset int) { + if x.ExtensionNumber == 0 { + return offset + } + offset += fastpb.WriteInt32(buf[offset:], 2, x.GetExtensionNumber()) + return offset +} + +func (x *ServerReflectionResponse) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField2(buf[offset:]) + offset += x.fastWriteField4(buf[offset:]) + offset += x.fastWriteField5(buf[offset:]) + offset += x.fastWriteField6(buf[offset:]) + offset += x.fastWriteField7(buf[offset:]) + return offset +} + +func (x *ServerReflectionResponse) fastWriteField1(buf []byte) (offset int) { + if x.ValidHost == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetValidHost()) + return offset +} + +func (x *ServerReflectionResponse) fastWriteField2(buf []byte) (offset int) { + if x.OriginalRequest == nil { + return offset + } + offset += fastpb.WriteMessage(buf[offset:], 2, x.GetOriginalRequest()) + return offset +} + +func (x *ServerReflectionResponse) fastWriteField4(buf []byte) (offset int) { + if x.GetFileDescriptorResponse() == nil { + return offset + } + offset += fastpb.WriteMessage(buf[offset:], 4, x.GetFileDescriptorResponse()) + return offset +} + +func (x *ServerReflectionResponse) fastWriteField5(buf []byte) (offset int) { + if x.GetAllExtensionNumbersResponse() == nil { + return offset + } + offset += fastpb.WriteMessage(buf[offset:], 5, x.GetAllExtensionNumbersResponse()) + return offset +} + +func (x *ServerReflectionResponse) fastWriteField6(buf []byte) (offset int) { + if x.GetListServicesResponse() == nil { + return offset + } + offset += fastpb.WriteMessage(buf[offset:], 6, x.GetListServicesResponse()) + return offset +} + +func (x *ServerReflectionResponse) fastWriteField7(buf []byte) (offset int) { + if x.GetErrorResponse() == nil { + return offset + } + offset += fastpb.WriteMessage(buf[offset:], 7, x.GetErrorResponse()) + return offset +} + +func (x *FileDescriptorResponse) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *FileDescriptorResponse) fastWriteField1(buf []byte) (offset int) { + if len(x.FileDescriptorProto) == 0 { + return offset + } + for i := range x.GetFileDescriptorProto() { + offset += fastpb.WriteBytes(buf[offset:], 1, x.GetFileDescriptorProto()[i]) + } + return offset +} + +func (x *ExtensionNumberResponse) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField2(buf[offset:]) + return offset +} + +func (x *ExtensionNumberResponse) fastWriteField1(buf []byte) (offset int) { + if x.BaseTypeName == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetBaseTypeName()) + return offset +} + +func (x *ExtensionNumberResponse) fastWriteField2(buf []byte) (offset int) { + if len(x.ExtensionNumber) == 0 { + return offset + } + offset += fastpb.WriteListPacked(buf[offset:], 2, len(x.GetExtensionNumber()), + func(buf []byte, numTagOrKey, numIdxOrVal int32) int { + offset := 0 + offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, x.GetExtensionNumber()[numIdxOrVal]) + return offset + }) + return offset +} + +func (x *ListServiceResponse) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *ListServiceResponse) fastWriteField1(buf []byte) (offset int) { + if x.Service == nil { + return offset + } + for i := range x.GetService() { + offset += fastpb.WriteMessage(buf[offset:], 1, x.GetService()[i]) + } + return offset +} + +func (x *ServiceResponse) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *ServiceResponse) fastWriteField1(buf []byte) (offset int) { + if x.Name == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetName()) + return offset +} + +func (x *ErrorResponse) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField2(buf[offset:]) + return offset +} + +func (x *ErrorResponse) fastWriteField1(buf []byte) (offset int) { + if x.ErrorCode == 0 { + return offset + } + offset += fastpb.WriteInt32(buf[offset:], 1, x.GetErrorCode()) + return offset +} + +func (x *ErrorResponse) fastWriteField2(buf []byte) (offset int) { + if x.ErrorMessage == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 2, x.GetErrorMessage()) + return offset +} + +func (x *ServerReflectionRequest) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField3() + n += x.sizeField4() + n += x.sizeField5() + n += x.sizeField6() + n += x.sizeField7() + return n +} + +func (x *ServerReflectionRequest) sizeField1() (n int) { + if x.Host == "" { + return n + } + n += fastpb.SizeString(1, x.GetHost()) + return n +} + +func (x *ServerReflectionRequest) sizeField3() (n int) { + if x.GetFileByFilename() == "" { + return n + } + n += fastpb.SizeString(3, x.GetFileByFilename()) + return n +} + +func (x *ServerReflectionRequest) sizeField4() (n int) { + if x.GetFileContainingSymbol() == "" { + return n + } + n += fastpb.SizeString(4, x.GetFileContainingSymbol()) + return n +} + +func (x *ServerReflectionRequest) sizeField5() (n int) { + if x.GetFileContainingExtension() == nil { + return n + } + n += fastpb.SizeMessage(5, x.GetFileContainingExtension()) + return n +} + +func (x *ServerReflectionRequest) sizeField6() (n int) { + if x.GetAllExtensionNumbersOfType() == "" { + return n + } + n += fastpb.SizeString(6, x.GetAllExtensionNumbersOfType()) + return n +} + +func (x *ServerReflectionRequest) sizeField7() (n int) { + if x.GetListServices() == "" { + return n + } + n += fastpb.SizeString(7, x.GetListServices()) + return n +} + +func (x *ExtensionRequest) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField2() + return n +} + +func (x *ExtensionRequest) sizeField1() (n int) { + if x.ContainingType == "" { + return n + } + n += fastpb.SizeString(1, x.GetContainingType()) + return n +} + +func (x *ExtensionRequest) sizeField2() (n int) { + if x.ExtensionNumber == 0 { + return n + } + n += fastpb.SizeInt32(2, x.GetExtensionNumber()) + return n +} + +func (x *ServerReflectionResponse) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField2() + n += x.sizeField4() + n += x.sizeField5() + n += x.sizeField6() + n += x.sizeField7() + return n +} + +func (x *ServerReflectionResponse) sizeField1() (n int) { + if x.ValidHost == "" { + return n + } + n += fastpb.SizeString(1, x.GetValidHost()) + return n +} + +func (x *ServerReflectionResponse) sizeField2() (n int) { + if x.OriginalRequest == nil { + return n + } + n += fastpb.SizeMessage(2, x.GetOriginalRequest()) + return n +} + +func (x *ServerReflectionResponse) sizeField4() (n int) { + if x.GetFileDescriptorResponse() == nil { + return n + } + n += fastpb.SizeMessage(4, x.GetFileDescriptorResponse()) + return n +} + +func (x *ServerReflectionResponse) sizeField5() (n int) { + if x.GetAllExtensionNumbersResponse() == nil { + return n + } + n += fastpb.SizeMessage(5, x.GetAllExtensionNumbersResponse()) + return n +} + +func (x *ServerReflectionResponse) sizeField6() (n int) { + if x.GetListServicesResponse() == nil { + return n + } + n += fastpb.SizeMessage(6, x.GetListServicesResponse()) + return n +} + +func (x *ServerReflectionResponse) sizeField7() (n int) { + if x.GetErrorResponse() == nil { + return n + } + n += fastpb.SizeMessage(7, x.GetErrorResponse()) + return n +} + +func (x *FileDescriptorResponse) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *FileDescriptorResponse) sizeField1() (n int) { + if len(x.FileDescriptorProto) == 0 { + return n + } + for i := range x.GetFileDescriptorProto() { + n += fastpb.SizeBytes(1, x.GetFileDescriptorProto()[i]) + } + return n +} + +func (x *ExtensionNumberResponse) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField2() + return n +} + +func (x *ExtensionNumberResponse) sizeField1() (n int) { + if x.BaseTypeName == "" { + return n + } + n += fastpb.SizeString(1, x.GetBaseTypeName()) + return n +} + +func (x *ExtensionNumberResponse) sizeField2() (n int) { + if len(x.ExtensionNumber) == 0 { + return n + } + n += fastpb.SizeListPacked(2, len(x.GetExtensionNumber()), + func(numTagOrKey, numIdxOrVal int32) int { + n := 0 + n += fastpb.SizeInt32(numTagOrKey, x.GetExtensionNumber()[numIdxOrVal]) + return n + }) + return n +} + +func (x *ListServiceResponse) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *ListServiceResponse) sizeField1() (n int) { + if x.Service == nil { + return n + } + for i := range x.GetService() { + n += fastpb.SizeMessage(1, x.GetService()[i]) + } + return n +} + +func (x *ServiceResponse) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *ServiceResponse) sizeField1() (n int) { + if x.Name == "" { + return n + } + n += fastpb.SizeString(1, x.GetName()) + return n +} + +func (x *ErrorResponse) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField2() + return n +} + +func (x *ErrorResponse) sizeField1() (n int) { + if x.ErrorCode == 0 { + return n + } + n += fastpb.SizeInt32(1, x.GetErrorCode()) + return n +} + +func (x *ErrorResponse) sizeField2() (n int) { + if x.ErrorMessage == "" { + return n + } + n += fastpb.SizeString(2, x.GetErrorMessage()) + return n +} + +var fieldIDToName_ServerReflectionRequest = map[int32]string{ + 1: "Host", + 3: "FileByFilename", + 4: "FileContainingSymbol", + 5: "FileContainingExtension", + 6: "AllExtensionNumbersOfType", + 7: "ListServices", +} + +var fieldIDToName_ExtensionRequest = map[int32]string{ + 1: "ContainingType", + 2: "ExtensionNumber", +} + +var fieldIDToName_ServerReflectionResponse = map[int32]string{ + 1: "ValidHost", + 2: "OriginalRequest", + 4: "FileDescriptorResponse", + 5: "AllExtensionNumbersResponse", + 6: "ListServicesResponse", + 7: "ErrorResponse", +} + +var fieldIDToName_FileDescriptorResponse = map[int32]string{ + 1: "FileDescriptorProto", +} + +var fieldIDToName_ExtensionNumberResponse = map[int32]string{ + 1: "BaseTypeName", + 2: "ExtensionNumber", +} + +var fieldIDToName_ListServiceResponse = map[int32]string{ + 1: "Service", +} + +var fieldIDToName_ServiceResponse = map[int32]string{ + 1: "Name", +} + +var fieldIDToName_ErrorResponse = map[int32]string{ + 1: "ErrorCode", + 2: "ErrorMessage", +} diff --git a/pkg/reflection/grpc/reflection/v1/reflection.pb.go b/pkg/reflection/grpc/reflection/v1/reflection.pb.go new file mode 100644 index 0000000000..8d34a2c7ab --- /dev/null +++ b/pkg/reflection/grpc/reflection/v1/reflection.pb.go @@ -0,0 +1,972 @@ +/* + * Copyright 2024 CloudWeGo 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. A more complete description of how +// server reflection works can be found at +// https://github.com/grpc/grpc/blob/master/doc/server-reflection.md +// +// The canonical version of this proto can be found at +// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v5.26.1 +// source: grpc/reflection/v1/reflection.proto + +package v1 + +import ( + context "context" + streaming "github.com/cloudwego/kitex/pkg/streaming" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// The message sent by the client when calling ServerReflectionInfo method. +type ServerReflectionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Host string `protobuf:"bytes,1,opt,name=host,proto3" 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 assignable to MessageRequest: + // + // *ServerReflectionRequest_FileByFilename + // *ServerReflectionRequest_FileContainingSymbol + // *ServerReflectionRequest_FileContainingExtension + // *ServerReflectionRequest_AllExtensionNumbersOfType + // *ServerReflectionRequest_ListServices + MessageRequest isServerReflectionRequest_MessageRequest `protobuf_oneof:"message_request"` +} + +func (x *ServerReflectionRequest) Reset() { + *x = ServerReflectionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServerReflectionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerReflectionRequest) ProtoMessage() {} + +func (x *ServerReflectionRequest) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerReflectionRequest.ProtoReflect.Descriptor instead. +func (*ServerReflectionRequest) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{0} +} + +func (x *ServerReflectionRequest) GetHost() string { + if x != nil { + return x.Host + } + return "" +} + +func (m *ServerReflectionRequest) GetMessageRequest() isServerReflectionRequest_MessageRequest { + if m != nil { + return m.MessageRequest + } + return nil +} + +func (x *ServerReflectionRequest) GetFileByFilename() string { + if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileByFilename); ok { + return x.FileByFilename + } + return "" +} + +func (x *ServerReflectionRequest) GetFileContainingSymbol() string { + if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileContainingSymbol); ok { + return x.FileContainingSymbol + } + return "" +} + +func (x *ServerReflectionRequest) GetFileContainingExtension() *ExtensionRequest { + if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileContainingExtension); ok { + return x.FileContainingExtension + } + return nil +} + +func (x *ServerReflectionRequest) GetAllExtensionNumbersOfType() string { + if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_AllExtensionNumbersOfType); ok { + return x.AllExtensionNumbersOfType + } + return "" +} + +func (x *ServerReflectionRequest) GetListServices() string { + if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_ListServices); ok { + return x.ListServices + } + return "" +} + +type isServerReflectionRequest_MessageRequest interface { + isServerReflectionRequest_MessageRequest() +} + +type ServerReflectionRequest_FileByFilename struct { + // Find a proto file by the file name. + FileByFilename string `protobuf:"bytes,3,opt,name=file_by_filename,json=fileByFilename,proto3,oneof"` +} + +type ServerReflectionRequest_FileContainingSymbol struct { + // Find the proto file that declares the given fully-qualified symbol name. + // This field should be a fully-qualified symbol name + // (e.g. .[.] or .). + FileContainingSymbol string `protobuf:"bytes,4,opt,name=file_containing_symbol,json=fileContainingSymbol,proto3,oneof"` +} + +type ServerReflectionRequest_FileContainingExtension struct { + // Find the proto file which defines an extension extending the given + // message type with the given field number. + FileContainingExtension *ExtensionRequest `protobuf:"bytes,5,opt,name=file_containing_extension,json=fileContainingExtension,proto3,oneof"` +} + +type ServerReflectionRequest_AllExtensionNumbersOfType struct { + // Finds the tag numbers used by all known extensions of the given message + // 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 + // . + AllExtensionNumbersOfType string `protobuf:"bytes,6,opt,name=all_extension_numbers_of_type,json=allExtensionNumbersOfType,proto3,oneof"` +} + +type ServerReflectionRequest_ListServices struct { + // List the full names of registered services. The content will not be + // checked. + ListServices string `protobuf:"bytes,7,opt,name=list_services,json=listServices,proto3,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() {} + +// The type name and extension number sent by the client when requesting +// file_containing_extension. +type ExtensionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Fully-qualified type name. The format should be . + ContainingType string `protobuf:"bytes,1,opt,name=containing_type,json=containingType,proto3" json:"containing_type,omitempty"` + ExtensionNumber int32 `protobuf:"varint,2,opt,name=extension_number,json=extensionNumber,proto3" json:"extension_number,omitempty"` +} + +func (x *ExtensionRequest) Reset() { + *x = ExtensionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ExtensionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExtensionRequest) ProtoMessage() {} + +func (x *ExtensionRequest) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExtensionRequest.ProtoReflect.Descriptor instead. +func (*ExtensionRequest) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{1} +} + +func (x *ExtensionRequest) GetContainingType() string { + if x != nil { + return x.ContainingType + } + return "" +} + +func (x *ExtensionRequest) GetExtensionNumber() int32 { + if x != nil { + return x.ExtensionNumber + } + return 0 +} + +// The message sent by the server to answer ServerReflectionInfo method. +type ServerReflectionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ValidHost string `protobuf:"bytes,1,opt,name=valid_host,json=validHost,proto3" json:"valid_host,omitempty"` + OriginalRequest *ServerReflectionRequest `protobuf:"bytes,2,opt,name=original_request,json=originalRequest,proto3" json:"original_request,omitempty"` + // The server sets one of the following fields according to the message_request + // in the request. + // + // Types that are assignable to MessageResponse: + // + // *ServerReflectionResponse_FileDescriptorResponse + // *ServerReflectionResponse_AllExtensionNumbersResponse + // *ServerReflectionResponse_ListServicesResponse + // *ServerReflectionResponse_ErrorResponse + MessageResponse isServerReflectionResponse_MessageResponse `protobuf_oneof:"message_response"` +} + +func (x *ServerReflectionResponse) Reset() { + *x = ServerReflectionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServerReflectionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerReflectionResponse) ProtoMessage() {} + +func (x *ServerReflectionResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerReflectionResponse.ProtoReflect.Descriptor instead. +func (*ServerReflectionResponse) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{2} +} + +func (x *ServerReflectionResponse) GetValidHost() string { + if x != nil { + return x.ValidHost + } + return "" +} + +func (x *ServerReflectionResponse) GetOriginalRequest() *ServerReflectionRequest { + if x != nil { + return x.OriginalRequest + } + return nil +} + +func (m *ServerReflectionResponse) GetMessageResponse() isServerReflectionResponse_MessageResponse { + if m != nil { + return m.MessageResponse + } + return nil +} + +func (x *ServerReflectionResponse) GetFileDescriptorResponse() *FileDescriptorResponse { + if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_FileDescriptorResponse); ok { + return x.FileDescriptorResponse + } + return nil +} + +func (x *ServerReflectionResponse) GetAllExtensionNumbersResponse() *ExtensionNumberResponse { + if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_AllExtensionNumbersResponse); ok { + return x.AllExtensionNumbersResponse + } + return nil +} + +func (x *ServerReflectionResponse) GetListServicesResponse() *ListServiceResponse { + if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_ListServicesResponse); ok { + return x.ListServicesResponse + } + return nil +} + +func (x *ServerReflectionResponse) GetErrorResponse() *ErrorResponse { + if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_ErrorResponse); ok { + return x.ErrorResponse + } + return nil +} + +type isServerReflectionResponse_MessageResponse interface { + isServerReflectionResponse_MessageResponse() +} + +type ServerReflectionResponse_FileDescriptorResponse struct { + // 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 *FileDescriptorResponse `protobuf:"bytes,4,opt,name=file_descriptor_response,json=fileDescriptorResponse,proto3,oneof"` +} + +type ServerReflectionResponse_AllExtensionNumbersResponse struct { + // This message is used to answer all_extension_numbers_of_type requests. + AllExtensionNumbersResponse *ExtensionNumberResponse `protobuf:"bytes,5,opt,name=all_extension_numbers_response,json=allExtensionNumbersResponse,proto3,oneof"` +} + +type ServerReflectionResponse_ListServicesResponse struct { + // This message is used to answer list_services requests. + ListServicesResponse *ListServiceResponse `protobuf:"bytes,6,opt,name=list_services_response,json=listServicesResponse,proto3,oneof"` +} + +type ServerReflectionResponse_ErrorResponse struct { + // This message is used when an error occurs. + ErrorResponse *ErrorResponse `protobuf:"bytes,7,opt,name=error_response,json=errorResponse,proto3,oneof"` +} + +func (*ServerReflectionResponse_FileDescriptorResponse) isServerReflectionResponse_MessageResponse() { +} + +func (*ServerReflectionResponse_AllExtensionNumbersResponse) isServerReflectionResponse_MessageResponse() { +} + +func (*ServerReflectionResponse_ListServicesResponse) isServerReflectionResponse_MessageResponse() {} + +func (*ServerReflectionResponse_ErrorResponse) isServerReflectionResponse_MessageResponse() {} + +// Serialized FileDescriptorProto messages sent by the server answering +// a file_by_filename, file_containing_symbol, or file_containing_extension +// request. +type FileDescriptorResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 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 (x *FileDescriptorResponse) Reset() { + *x = FileDescriptorResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FileDescriptorResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FileDescriptorResponse) ProtoMessage() {} + +func (x *FileDescriptorResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FileDescriptorResponse.ProtoReflect.Descriptor instead. +func (*FileDescriptorResponse) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{3} +} + +func (x *FileDescriptorResponse) GetFileDescriptorProto() [][]byte { + if x != nil { + return x.FileDescriptorProto + } + return nil +} + +// A list of extension numbers sent by the server answering +// all_extension_numbers_of_type request. +type ExtensionNumberResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Full name of the base type, including the package name. The format + // is . + BaseTypeName string `protobuf:"bytes,1,opt,name=base_type_name,json=baseTypeName,proto3" json:"base_type_name,omitempty"` + ExtensionNumber []int32 `protobuf:"varint,2,rep,packed,name=extension_number,json=extensionNumber,proto3" json:"extension_number,omitempty"` +} + +func (x *ExtensionNumberResponse) Reset() { + *x = ExtensionNumberResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ExtensionNumberResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExtensionNumberResponse) ProtoMessage() {} + +func (x *ExtensionNumberResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExtensionNumberResponse.ProtoReflect.Descriptor instead. +func (*ExtensionNumberResponse) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{4} +} + +func (x *ExtensionNumberResponse) GetBaseTypeName() string { + if x != nil { + return x.BaseTypeName + } + return "" +} + +func (x *ExtensionNumberResponse) GetExtensionNumber() []int32 { + if x != nil { + return x.ExtensionNumber + } + return nil +} + +// A list of ServiceResponse sent by the server answering list_services request. +type ListServiceResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 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,proto3" json:"service,omitempty"` +} + +func (x *ListServiceResponse) Reset() { + *x = ListServiceResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListServiceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListServiceResponse) ProtoMessage() {} + +func (x *ListServiceResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListServiceResponse.ProtoReflect.Descriptor instead. +func (*ListServiceResponse) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{5} +} + +func (x *ListServiceResponse) GetService() []*ServiceResponse { + if x != nil { + return x.Service + } + return nil +} + +// The information of a single service used by ListServiceResponse to answer +// list_services request. +type ServiceResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Full name of a registered service, including its package name. The format + // is . + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *ServiceResponse) Reset() { + *x = ServiceResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServiceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServiceResponse) ProtoMessage() {} + +func (x *ServiceResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServiceResponse.ProtoReflect.Descriptor instead. +func (*ServiceResponse) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{6} +} + +func (x *ServiceResponse) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// The error code and error message sent by the server when an error occurs. +type ErrorResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // This field uses the error codes defined in grpc::StatusCode. + ErrorCode int32 `protobuf:"varint,1,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"` + ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` +} + +func (x *ErrorResponse) Reset() { + *x = ErrorResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ErrorResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ErrorResponse) ProtoMessage() {} + +func (x *ErrorResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ErrorResponse.ProtoReflect.Descriptor instead. +func (*ErrorResponse) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{7} +} + +func (x *ErrorResponse) GetErrorCode() int32 { + if x != nil { + return x.ErrorCode + } + return 0 +} + +func (x *ErrorResponse) GetErrorMessage() string { + if x != nil { + return x.ErrorMessage + } + return "" +} + +var File_grpc_reflection_v1_reflection_proto protoreflect.FileDescriptor + +var file_grpc_reflection_v1_reflection_proto_rawDesc = []byte{ + 0x0a, 0x23, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x22, 0xf3, 0x02, 0x0a, 0x17, 0x53, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x66, 0x69, 0x6c, + 0x65, 0x5f, 0x62, 0x79, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0e, 0x66, 0x69, 0x6c, 0x65, 0x42, 0x79, 0x46, 0x69, 0x6c, + 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x16, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x63, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x14, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x12, 0x62, 0x0a, + 0x19, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, + 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x24, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x17, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x42, 0x0a, 0x1d, 0x61, 0x6c, 0x6c, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x19, 0x61, 0x6c, 0x6c, 0x45, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x4f, + 0x66, 0x54, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x0d, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0c, + 0x6c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x42, 0x11, 0x0a, 0x0f, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, + 0x66, 0x0a, 0x10, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, + 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10, + 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0xae, 0x04, 0x0a, 0x18, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x5f, 0x68, 0x6f, + 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x48, + 0x6f, 0x73, 0x74, 0x12, 0x56, 0x0a, 0x10, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, + 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0f, 0x6f, 0x72, 0x69, 0x67, + 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x66, 0x0a, 0x18, 0x66, + 0x69, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x5f, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, + 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x16, 0x66, 0x69, 0x6c, + 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x72, 0x0a, 0x1e, 0x61, 0x6c, 0x6c, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x5f, 0x72, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x67, 0x72, + 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, + 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x1b, 0x61, 0x6c, 0x6c, 0x45, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5f, 0x0a, 0x16, 0x6c, 0x69, 0x73, 0x74, 0x5f, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, + 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, + 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x48, 0x00, 0x52, 0x14, 0x6c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0e, 0x65, 0x72, 0x72, 0x6f, + 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x21, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x12, 0x0a, 0x10, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4c, 0x0a, 0x16, 0x46, 0x69, 0x6c, 0x65, + 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x32, 0x0a, 0x15, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0c, 0x52, 0x13, 0x66, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, + 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6a, 0x0a, 0x17, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, + 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x62, 0x61, 0x73, 0x65, 0x54, + 0x79, 0x70, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x05, 0x52, 0x0f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x22, 0x54, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x07, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x67, 0x72, 0x70, + 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, + 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x25, 0x0a, 0x0f, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, + 0x53, 0x0a, 0x0d, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x23, 0x0a, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x32, 0x89, 0x01, 0x0a, 0x10, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, + 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x75, 0x0a, 0x14, 0x53, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, + 0x6f, 0x12, 0x2b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, + 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, + 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, + 0x42, 0x6e, 0x0a, 0x15, 0x69, 0x6f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x42, 0x15, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, + 0x6c, 0x6f, 0x75, 0x64, 0x77, 0x65, 0x67, 0x6f, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x2f, 0x70, + 0x6b, 0x67, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x67, 0x72, + 0x70, 0x63, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_grpc_reflection_v1_reflection_proto_rawDescOnce sync.Once + file_grpc_reflection_v1_reflection_proto_rawDescData = file_grpc_reflection_v1_reflection_proto_rawDesc +) + +func file_grpc_reflection_v1_reflection_proto_rawDescGZIP() []byte { + file_grpc_reflection_v1_reflection_proto_rawDescOnce.Do(func() { + file_grpc_reflection_v1_reflection_proto_rawDescData = protoimpl.X.CompressGZIP(file_grpc_reflection_v1_reflection_proto_rawDescData) + }) + return file_grpc_reflection_v1_reflection_proto_rawDescData +} + +var file_grpc_reflection_v1_reflection_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_grpc_reflection_v1_reflection_proto_goTypes = []interface{}{ + (*ServerReflectionRequest)(nil), // 0: grpc.reflection.v1.ServerReflectionRequest + (*ExtensionRequest)(nil), // 1: grpc.reflection.v1.ExtensionRequest + (*ServerReflectionResponse)(nil), // 2: grpc.reflection.v1.ServerReflectionResponse + (*FileDescriptorResponse)(nil), // 3: grpc.reflection.v1.FileDescriptorResponse + (*ExtensionNumberResponse)(nil), // 4: grpc.reflection.v1.ExtensionNumberResponse + (*ListServiceResponse)(nil), // 5: grpc.reflection.v1.ListServiceResponse + (*ServiceResponse)(nil), // 6: grpc.reflection.v1.ServiceResponse + (*ErrorResponse)(nil), // 7: grpc.reflection.v1.ErrorResponse +} +var file_grpc_reflection_v1_reflection_proto_depIdxs = []int32{ + 1, // 0: grpc.reflection.v1.ServerReflectionRequest.file_containing_extension:type_name -> grpc.reflection.v1.ExtensionRequest + 0, // 1: grpc.reflection.v1.ServerReflectionResponse.original_request:type_name -> grpc.reflection.v1.ServerReflectionRequest + 3, // 2: grpc.reflection.v1.ServerReflectionResponse.file_descriptor_response:type_name -> grpc.reflection.v1.FileDescriptorResponse + 4, // 3: grpc.reflection.v1.ServerReflectionResponse.all_extension_numbers_response:type_name -> grpc.reflection.v1.ExtensionNumberResponse + 5, // 4: grpc.reflection.v1.ServerReflectionResponse.list_services_response:type_name -> grpc.reflection.v1.ListServiceResponse + 7, // 5: grpc.reflection.v1.ServerReflectionResponse.error_response:type_name -> grpc.reflection.v1.ErrorResponse + 6, // 6: grpc.reflection.v1.ListServiceResponse.service:type_name -> grpc.reflection.v1.ServiceResponse + 0, // 7: grpc.reflection.v1.ServerReflection.ServerReflectionInfo:input_type -> grpc.reflection.v1.ServerReflectionRequest + 2, // 8: grpc.reflection.v1.ServerReflection.ServerReflectionInfo:output_type -> grpc.reflection.v1.ServerReflectionResponse + 8, // [8:9] is the sub-list for method output_type + 7, // [7:8] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_grpc_reflection_v1_reflection_proto_init() } +func file_grpc_reflection_v1_reflection_proto_init() { + if File_grpc_reflection_v1_reflection_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_grpc_reflection_v1_reflection_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServerReflectionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1_reflection_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ExtensionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1_reflection_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServerReflectionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1_reflection_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FileDescriptorResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1_reflection_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ExtensionNumberResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1_reflection_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListServiceResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1_reflection_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServiceResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1_reflection_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ErrorResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_grpc_reflection_v1_reflection_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*ServerReflectionRequest_FileByFilename)(nil), + (*ServerReflectionRequest_FileContainingSymbol)(nil), + (*ServerReflectionRequest_FileContainingExtension)(nil), + (*ServerReflectionRequest_AllExtensionNumbersOfType)(nil), + (*ServerReflectionRequest_ListServices)(nil), + } + file_grpc_reflection_v1_reflection_proto_msgTypes[2].OneofWrappers = []interface{}{ + (*ServerReflectionResponse_FileDescriptorResponse)(nil), + (*ServerReflectionResponse_AllExtensionNumbersResponse)(nil), + (*ServerReflectionResponse_ListServicesResponse)(nil), + (*ServerReflectionResponse_ErrorResponse)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_grpc_reflection_v1_reflection_proto_rawDesc, + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_grpc_reflection_v1_reflection_proto_goTypes, + DependencyIndexes: file_grpc_reflection_v1_reflection_proto_depIdxs, + MessageInfos: file_grpc_reflection_v1_reflection_proto_msgTypes, + }.Build() + File_grpc_reflection_v1_reflection_proto = out.File + file_grpc_reflection_v1_reflection_proto_rawDesc = nil + file_grpc_reflection_v1_reflection_proto_goTypes = nil + file_grpc_reflection_v1_reflection_proto_depIdxs = nil +} + +var _ context.Context + +// Code generated by Kitex v0.9.1. DO NOT EDIT. + +type ServerReflection interface { + ServerReflectionInfo(stream ServerReflection_ServerReflectionInfoServer) (err error) +} + +type ServerReflection_ServerReflectionInfoServer interface { + streaming.Stream + Recv() (*ServerReflectionRequest, error) + Send(*ServerReflectionResponse) error +} diff --git a/pkg/reflection/grpc/reflection/v1/reflection.proto b/pkg/reflection/grpc/reflection/v1/reflection.proto new file mode 100644 index 0000000000..4726a1dcec --- /dev/null +++ b/pkg/reflection/grpc/reflection/v1/reflection.proto @@ -0,0 +1,146 @@ +// Copyright 2016 The 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. A more complete description of how +// server reflection works can be found at +// https://github.com/grpc/grpc/blob/master/doc/server-reflection.md +// +// The canonical version of this proto can be found at +// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto + +syntax = "proto3"; + +package grpc.reflection.v1; + +option go_package = "grpc/reflection/v1"; +option java_multiple_files = true; +option java_package = "io.grpc.reflection.v1"; +option java_outer_classname = "ServerReflectionProto"; + +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. .[.] or .). + 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 the given message + // 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 + // . + 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 . + 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 sets 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 requests. + ExtensionNumberResponse all_extension_numbers_response = 5; + + // This message is used to answer list_services requests. + 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 . + 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 . + 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; +} \ No newline at end of file diff --git a/pkg/reflection/grpc/reflection/v1/serverreflection/client.go b/pkg/reflection/grpc/reflection/v1/serverreflection/client.go new file mode 100644 index 0000000000..f6fac16b10 --- /dev/null +++ b/pkg/reflection/grpc/reflection/v1/serverreflection/client.go @@ -0,0 +1,117 @@ +/* + * Copyright 2024 CloudWeGo 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. + */ + +// Code generated by Kitex v0.9.1. DO NOT EDIT. + +package serverreflection + +import ( + "context" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + v1 "github.com/cloudwego/kitex/pkg/reflection/grpc/reflection/v1" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" + "github.com/cloudwego/kitex/client/streamclient" + "github.com/cloudwego/kitex/client/callopt/streamcall" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + ServerReflectionInfo(ctx context.Context, callOptions ...callopt.Option) (stream ServerReflection_ServerReflectionInfoClient, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + ServerReflectionInfo(ctx context.Context, callOptions ...streamcall.Option) (stream ServerReflection_ServerReflectionInfoClient, err error) +} + +type ServerReflection_ServerReflectionInfoClient interface { + streaming.Stream + Send(*v1.ServerReflectionRequest) error + Recv() (*v1.ServerReflectionResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, client.WithTransportProtocol(transport.GRPC)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kServerReflectionClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kServerReflectionClient struct { + *kClient +} + +func (p *kServerReflectionClient) ServerReflectionInfo(ctx context.Context, callOptions ...callopt.Option) (stream ServerReflection_ServerReflectionInfoClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.ServerReflectionInfo(ctx) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kServerReflectionStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kServerReflectionStreamClient struct { + *kClient +} + +func (p *kServerReflectionStreamClient) ServerReflectionInfo(ctx context.Context, callOptions ...streamcall.Option) (stream ServerReflection_ServerReflectionInfoClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.ServerReflectionInfo(ctx) +} diff --git a/pkg/reflection/grpc/reflection/v1/serverreflection/serverreflection.go b/pkg/reflection/grpc/reflection/v1/serverreflection/serverreflection.go new file mode 100644 index 0000000000..76c81a4129 --- /dev/null +++ b/pkg/reflection/grpc/reflection/v1/serverreflection/serverreflection.go @@ -0,0 +1,300 @@ +/* + * Copyright 2024 CloudWeGo 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. + */ + +// Code generated by Kitex v0.9.1. DO NOT EDIT. + +package serverreflection + +import ( + "context" + "errors" + "fmt" + client "github.com/cloudwego/kitex/client" + v1 "github.com/cloudwego/kitex/pkg/reflection/grpc/reflection/v1" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" + proto "google.golang.org/protobuf/proto" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "ServerReflectionInfo": kitex.NewMethodInfo( + serverReflectionInfoHandler, + newServerReflectionInfoArgs, + newServerReflectionInfoResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + serverReflectionServiceInfo = NewServiceInfo() + serverReflectionServiceInfoForClient = NewServiceInfoForClient() + serverReflectionServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return serverReflectionServiceInfo +} + +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return serverReflectionServiceInfoForStreamClient +} + +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return serverReflectionServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "ServerReflection" + handlerType := (*v1.ServerReflection)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "grpc.reflection.v1", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Protobuf, + KiteXGenVersion: "v0.9.1", + Extra: extra, + } + return svcInfo +} + +func serverReflectionInfoHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + streamingArgs, ok := arg.(*streaming.Args) + if !ok { + return errInvalidMessageType + } + st := streamingArgs.Stream + stream := &serverReflectionServerReflectionInfoServer{st} + return handler.(v1.ServerReflection).ServerReflectionInfo(stream) +} + +type serverReflectionServerReflectionInfoClient struct { + streaming.Stream +} + +func (x *serverReflectionServerReflectionInfoClient) DoFinish(err error) { + if finisher, ok := x.Stream.(streaming.WithDoFinish); ok { + finisher.DoFinish(err) + } else { + panic(fmt.Sprintf("streaming.WithDoFinish is not implemented by %T", x.Stream)) + } +} +func (x *serverReflectionServerReflectionInfoClient) Send(m *v1.ServerReflectionRequest) error { + return x.Stream.SendMsg(m) +} +func (x *serverReflectionServerReflectionInfoClient) Recv() (*v1.ServerReflectionResponse, error) { + m := new(v1.ServerReflectionResponse) + return m, x.Stream.RecvMsg(m) +} + +type serverReflectionServerReflectionInfoServer struct { + streaming.Stream +} + +func (x *serverReflectionServerReflectionInfoServer) Send(m *v1.ServerReflectionResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *serverReflectionServerReflectionInfoServer) Recv() (*v1.ServerReflectionRequest, error) { + m := new(v1.ServerReflectionRequest) + return m, x.Stream.RecvMsg(m) +} + +func newServerReflectionInfoArgs() interface{} { + return &ServerReflectionInfoArgs{} +} + +func newServerReflectionInfoResult() interface{} { + return &ServerReflectionInfoResult{} +} + +type ServerReflectionInfoArgs struct { + Req *v1.ServerReflectionRequest +} + +func (p *ServerReflectionInfoArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetReq() { + p.Req = new(v1.ServerReflectionRequest) + } + return p.Req.FastRead(buf, _type, number) +} + +func (p *ServerReflectionInfoArgs) FastWrite(buf []byte) (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.FastWrite(buf) +} + +func (p *ServerReflectionInfoArgs) Size() (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.Size() +} + +func (p *ServerReflectionInfoArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, nil + } + return proto.Marshal(p.Req) +} + +func (p *ServerReflectionInfoArgs) Unmarshal(in []byte) error { + msg := new(v1.ServerReflectionRequest) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var ServerReflectionInfoArgs_Req_DEFAULT *v1.ServerReflectionRequest + +func (p *ServerReflectionInfoArgs) GetReq() *v1.ServerReflectionRequest { + if !p.IsSetReq() { + return ServerReflectionInfoArgs_Req_DEFAULT + } + return p.Req +} + +func (p *ServerReflectionInfoArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *ServerReflectionInfoArgs) GetFirstArgument() interface{} { + return p.Req +} + +type ServerReflectionInfoResult struct { + Success *v1.ServerReflectionResponse +} + +var ServerReflectionInfoResult_Success_DEFAULT *v1.ServerReflectionResponse + +func (p *ServerReflectionInfoResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetSuccess() { + p.Success = new(v1.ServerReflectionResponse) + } + return p.Success.FastRead(buf, _type, number) +} + +func (p *ServerReflectionInfoResult) FastWrite(buf []byte) (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.FastWrite(buf) +} + +func (p *ServerReflectionInfoResult) Size() (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.Size() +} + +func (p *ServerReflectionInfoResult) Marshal(out []byte) ([]byte, error) { + if !p.IsSetSuccess() { + return out, nil + } + return proto.Marshal(p.Success) +} + +func (p *ServerReflectionInfoResult) Unmarshal(in []byte) error { + msg := new(v1.ServerReflectionResponse) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Success = msg + return nil +} + +func (p *ServerReflectionInfoResult) GetSuccess() *v1.ServerReflectionResponse { + if !p.IsSetSuccess() { + return ServerReflectionInfoResult_Success_DEFAULT + } + return p.Success +} + +func (p *ServerReflectionInfoResult) SetSuccess(x interface{}) { + p.Success = x.(*v1.ServerReflectionResponse) +} + +func (p *ServerReflectionInfoResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ServerReflectionInfoResult) GetResult() interface{} { + return p.Success +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) ServerReflectionInfo(ctx context.Context) (ServerReflection_ServerReflectionInfoClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "ServerReflectionInfo", nil, res) + if err != nil { + return nil, err + } + stream := &serverReflectionServerReflectionInfoClient{res.Stream} + return stream, nil +} diff --git a/pkg/reflection/grpc/reflection/v1alpha/reflection.pb.fast.go b/pkg/reflection/grpc/reflection/v1alpha/reflection.pb.fast.go new file mode 100644 index 0000000000..0b66c53448 --- /dev/null +++ b/pkg/reflection/grpc/reflection/v1alpha/reflection.pb.fast.go @@ -0,0 +1,979 @@ +/* + * Copyright 2024 CloudWeGo 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. + */ + +// Code generated by Fastpb v0.0.2. DO NOT EDIT. + +package v1alpha + +import ( + fmt "fmt" + fastpb "github.com/cloudwego/fastpb" +) + +var ( + _ = fmt.Errorf + _ = fastpb.Skip +) + +func (x *ServerReflectionRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 3: + offset, err = x.fastReadField3(buf, _type) + if err != nil { + goto ReadFieldError + } + case 4: + offset, err = x.fastReadField4(buf, _type) + if err != nil { + goto ReadFieldError + } + case 5: + offset, err = x.fastReadField5(buf, _type) + if err != nil { + goto ReadFieldError + } + case 6: + offset, err = x.fastReadField6(buf, _type) + if err != nil { + goto ReadFieldError + } + case 7: + offset, err = x.fastReadField7(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ServerReflectionRequest[number], err) +} + +func (x *ServerReflectionRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Host, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ServerReflectionRequest) fastReadField3(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionRequest_FileByFilename + x.MessageRequest = &ov + ov.FileByFilename, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ServerReflectionRequest) fastReadField4(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionRequest_FileContainingSymbol + x.MessageRequest = &ov + ov.FileContainingSymbol, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ServerReflectionRequest) fastReadField5(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionRequest_FileContainingExtension + x.MessageRequest = &ov + var v ExtensionRequest + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + ov.FileContainingExtension = &v + return offset, nil +} + +func (x *ServerReflectionRequest) fastReadField6(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionRequest_AllExtensionNumbersOfType + x.MessageRequest = &ov + ov.AllExtensionNumbersOfType, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ServerReflectionRequest) fastReadField7(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionRequest_ListServices + x.MessageRequest = &ov + ov.ListServices, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ExtensionRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 2: + offset, err = x.fastReadField2(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ExtensionRequest[number], err) +} + +func (x *ExtensionRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.ContainingType, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ExtensionRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { + x.ExtensionNumber, offset, err = fastpb.ReadInt32(buf, _type) + return offset, err +} + +func (x *ServerReflectionResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 2: + offset, err = x.fastReadField2(buf, _type) + if err != nil { + goto ReadFieldError + } + case 4: + offset, err = x.fastReadField4(buf, _type) + if err != nil { + goto ReadFieldError + } + case 5: + offset, err = x.fastReadField5(buf, _type) + if err != nil { + goto ReadFieldError + } + case 6: + offset, err = x.fastReadField6(buf, _type) + if err != nil { + goto ReadFieldError + } + case 7: + offset, err = x.fastReadField7(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ServerReflectionResponse[number], err) +} + +func (x *ServerReflectionResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.ValidHost, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ServerReflectionResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { + var v ServerReflectionRequest + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + x.OriginalRequest = &v + return offset, nil +} + +func (x *ServerReflectionResponse) fastReadField4(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionResponse_FileDescriptorResponse + x.MessageResponse = &ov + var v FileDescriptorResponse + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + ov.FileDescriptorResponse = &v + return offset, nil +} + +func (x *ServerReflectionResponse) fastReadField5(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionResponse_AllExtensionNumbersResponse + x.MessageResponse = &ov + var v ExtensionNumberResponse + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + ov.AllExtensionNumbersResponse = &v + return offset, nil +} + +func (x *ServerReflectionResponse) fastReadField6(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionResponse_ListServicesResponse + x.MessageResponse = &ov + var v ListServiceResponse + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + ov.ListServicesResponse = &v + return offset, nil +} + +func (x *ServerReflectionResponse) fastReadField7(buf []byte, _type int8) (offset int, err error) { + var ov ServerReflectionResponse_ErrorResponse + x.MessageResponse = &ov + var v ErrorResponse + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + ov.ErrorResponse = &v + return offset, nil +} + +func (x *FileDescriptorResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_FileDescriptorResponse[number], err) +} + +func (x *FileDescriptorResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { + var v []byte + v, offset, err = fastpb.ReadBytes(buf, _type) + if err != nil { + return offset, err + } + x.FileDescriptorProto = append(x.FileDescriptorProto, v) + return offset, err +} + +func (x *ExtensionNumberResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 2: + offset, err = x.fastReadField2(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ExtensionNumberResponse[number], err) +} + +func (x *ExtensionNumberResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.BaseTypeName, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ExtensionNumberResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { + offset, err = fastpb.ReadList(buf, _type, + func(buf []byte, _type int8) (n int, err error) { + var v int32 + v, offset, err = fastpb.ReadInt32(buf, _type) + if err != nil { + return offset, err + } + x.ExtensionNumber = append(x.ExtensionNumber, v) + return offset, err + }) + return offset, err +} + +func (x *ListServiceResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ListServiceResponse[number], err) +} + +func (x *ListServiceResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { + var v ServiceResponse + offset, err = fastpb.ReadMessage(buf, _type, &v) + if err != nil { + return offset, err + } + x.Service = append(x.Service, &v) + return offset, nil +} + +func (x *ServiceResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ServiceResponse[number], err) +} + +func (x *ServiceResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Name, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ErrorResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 2: + offset, err = x.fastReadField2(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_ErrorResponse[number], err) +} + +func (x *ErrorResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.ErrorCode, offset, err = fastpb.ReadInt32(buf, _type) + return offset, err +} + +func (x *ErrorResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { + x.ErrorMessage, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *ServerReflectionRequest) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField3(buf[offset:]) + offset += x.fastWriteField4(buf[offset:]) + offset += x.fastWriteField5(buf[offset:]) + offset += x.fastWriteField6(buf[offset:]) + offset += x.fastWriteField7(buf[offset:]) + return offset +} + +func (x *ServerReflectionRequest) fastWriteField1(buf []byte) (offset int) { + if x.Host == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetHost()) + return offset +} + +func (x *ServerReflectionRequest) fastWriteField3(buf []byte) (offset int) { + if x.GetFileByFilename() == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 3, x.GetFileByFilename()) + return offset +} + +func (x *ServerReflectionRequest) fastWriteField4(buf []byte) (offset int) { + if x.GetFileContainingSymbol() == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 4, x.GetFileContainingSymbol()) + return offset +} + +func (x *ServerReflectionRequest) fastWriteField5(buf []byte) (offset int) { + if x.GetFileContainingExtension() == nil { + return offset + } + offset += fastpb.WriteMessage(buf[offset:], 5, x.GetFileContainingExtension()) + return offset +} + +func (x *ServerReflectionRequest) fastWriteField6(buf []byte) (offset int) { + if x.GetAllExtensionNumbersOfType() == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 6, x.GetAllExtensionNumbersOfType()) + return offset +} + +func (x *ServerReflectionRequest) fastWriteField7(buf []byte) (offset int) { + if x.GetListServices() == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 7, x.GetListServices()) + return offset +} + +func (x *ExtensionRequest) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField2(buf[offset:]) + return offset +} + +func (x *ExtensionRequest) fastWriteField1(buf []byte) (offset int) { + if x.ContainingType == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetContainingType()) + return offset +} + +func (x *ExtensionRequest) fastWriteField2(buf []byte) (offset int) { + if x.ExtensionNumber == 0 { + return offset + } + offset += fastpb.WriteInt32(buf[offset:], 2, x.GetExtensionNumber()) + return offset +} + +func (x *ServerReflectionResponse) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField2(buf[offset:]) + offset += x.fastWriteField4(buf[offset:]) + offset += x.fastWriteField5(buf[offset:]) + offset += x.fastWriteField6(buf[offset:]) + offset += x.fastWriteField7(buf[offset:]) + return offset +} + +func (x *ServerReflectionResponse) fastWriteField1(buf []byte) (offset int) { + if x.ValidHost == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetValidHost()) + return offset +} + +func (x *ServerReflectionResponse) fastWriteField2(buf []byte) (offset int) { + if x.OriginalRequest == nil { + return offset + } + offset += fastpb.WriteMessage(buf[offset:], 2, x.GetOriginalRequest()) + return offset +} + +func (x *ServerReflectionResponse) fastWriteField4(buf []byte) (offset int) { + if x.GetFileDescriptorResponse() == nil { + return offset + } + offset += fastpb.WriteMessage(buf[offset:], 4, x.GetFileDescriptorResponse()) + return offset +} + +func (x *ServerReflectionResponse) fastWriteField5(buf []byte) (offset int) { + if x.GetAllExtensionNumbersResponse() == nil { + return offset + } + offset += fastpb.WriteMessage(buf[offset:], 5, x.GetAllExtensionNumbersResponse()) + return offset +} + +func (x *ServerReflectionResponse) fastWriteField6(buf []byte) (offset int) { + if x.GetListServicesResponse() == nil { + return offset + } + offset += fastpb.WriteMessage(buf[offset:], 6, x.GetListServicesResponse()) + return offset +} + +func (x *ServerReflectionResponse) fastWriteField7(buf []byte) (offset int) { + if x.GetErrorResponse() == nil { + return offset + } + offset += fastpb.WriteMessage(buf[offset:], 7, x.GetErrorResponse()) + return offset +} + +func (x *FileDescriptorResponse) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *FileDescriptorResponse) fastWriteField1(buf []byte) (offset int) { + if len(x.FileDescriptorProto) == 0 { + return offset + } + for i := range x.GetFileDescriptorProto() { + offset += fastpb.WriteBytes(buf[offset:], 1, x.GetFileDescriptorProto()[i]) + } + return offset +} + +func (x *ExtensionNumberResponse) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField2(buf[offset:]) + return offset +} + +func (x *ExtensionNumberResponse) fastWriteField1(buf []byte) (offset int) { + if x.BaseTypeName == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetBaseTypeName()) + return offset +} + +func (x *ExtensionNumberResponse) fastWriteField2(buf []byte) (offset int) { + if len(x.ExtensionNumber) == 0 { + return offset + } + offset += fastpb.WriteListPacked(buf[offset:], 2, len(x.GetExtensionNumber()), + func(buf []byte, numTagOrKey, numIdxOrVal int32) int { + offset := 0 + offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, x.GetExtensionNumber()[numIdxOrVal]) + return offset + }) + return offset +} + +func (x *ListServiceResponse) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *ListServiceResponse) fastWriteField1(buf []byte) (offset int) { + if x.Service == nil { + return offset + } + for i := range x.GetService() { + offset += fastpb.WriteMessage(buf[offset:], 1, x.GetService()[i]) + } + return offset +} + +func (x *ServiceResponse) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *ServiceResponse) fastWriteField1(buf []byte) (offset int) { + if x.Name == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetName()) + return offset +} + +func (x *ErrorResponse) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField2(buf[offset:]) + return offset +} + +func (x *ErrorResponse) fastWriteField1(buf []byte) (offset int) { + if x.ErrorCode == 0 { + return offset + } + offset += fastpb.WriteInt32(buf[offset:], 1, x.GetErrorCode()) + return offset +} + +func (x *ErrorResponse) fastWriteField2(buf []byte) (offset int) { + if x.ErrorMessage == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 2, x.GetErrorMessage()) + return offset +} + +func (x *ServerReflectionRequest) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField3() + n += x.sizeField4() + n += x.sizeField5() + n += x.sizeField6() + n += x.sizeField7() + return n +} + +func (x *ServerReflectionRequest) sizeField1() (n int) { + if x.Host == "" { + return n + } + n += fastpb.SizeString(1, x.GetHost()) + return n +} + +func (x *ServerReflectionRequest) sizeField3() (n int) { + if x.GetFileByFilename() == "" { + return n + } + n += fastpb.SizeString(3, x.GetFileByFilename()) + return n +} + +func (x *ServerReflectionRequest) sizeField4() (n int) { + if x.GetFileContainingSymbol() == "" { + return n + } + n += fastpb.SizeString(4, x.GetFileContainingSymbol()) + return n +} + +func (x *ServerReflectionRequest) sizeField5() (n int) { + if x.GetFileContainingExtension() == nil { + return n + } + n += fastpb.SizeMessage(5, x.GetFileContainingExtension()) + return n +} + +func (x *ServerReflectionRequest) sizeField6() (n int) { + if x.GetAllExtensionNumbersOfType() == "" { + return n + } + n += fastpb.SizeString(6, x.GetAllExtensionNumbersOfType()) + return n +} + +func (x *ServerReflectionRequest) sizeField7() (n int) { + if x.GetListServices() == "" { + return n + } + n += fastpb.SizeString(7, x.GetListServices()) + return n +} + +func (x *ExtensionRequest) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField2() + return n +} + +func (x *ExtensionRequest) sizeField1() (n int) { + if x.ContainingType == "" { + return n + } + n += fastpb.SizeString(1, x.GetContainingType()) + return n +} + +func (x *ExtensionRequest) sizeField2() (n int) { + if x.ExtensionNumber == 0 { + return n + } + n += fastpb.SizeInt32(2, x.GetExtensionNumber()) + return n +} + +func (x *ServerReflectionResponse) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField2() + n += x.sizeField4() + n += x.sizeField5() + n += x.sizeField6() + n += x.sizeField7() + return n +} + +func (x *ServerReflectionResponse) sizeField1() (n int) { + if x.ValidHost == "" { + return n + } + n += fastpb.SizeString(1, x.GetValidHost()) + return n +} + +func (x *ServerReflectionResponse) sizeField2() (n int) { + if x.OriginalRequest == nil { + return n + } + n += fastpb.SizeMessage(2, x.GetOriginalRequest()) + return n +} + +func (x *ServerReflectionResponse) sizeField4() (n int) { + if x.GetFileDescriptorResponse() == nil { + return n + } + n += fastpb.SizeMessage(4, x.GetFileDescriptorResponse()) + return n +} + +func (x *ServerReflectionResponse) sizeField5() (n int) { + if x.GetAllExtensionNumbersResponse() == nil { + return n + } + n += fastpb.SizeMessage(5, x.GetAllExtensionNumbersResponse()) + return n +} + +func (x *ServerReflectionResponse) sizeField6() (n int) { + if x.GetListServicesResponse() == nil { + return n + } + n += fastpb.SizeMessage(6, x.GetListServicesResponse()) + return n +} + +func (x *ServerReflectionResponse) sizeField7() (n int) { + if x.GetErrorResponse() == nil { + return n + } + n += fastpb.SizeMessage(7, x.GetErrorResponse()) + return n +} + +func (x *FileDescriptorResponse) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *FileDescriptorResponse) sizeField1() (n int) { + if len(x.FileDescriptorProto) == 0 { + return n + } + for i := range x.GetFileDescriptorProto() { + n += fastpb.SizeBytes(1, x.GetFileDescriptorProto()[i]) + } + return n +} + +func (x *ExtensionNumberResponse) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField2() + return n +} + +func (x *ExtensionNumberResponse) sizeField1() (n int) { + if x.BaseTypeName == "" { + return n + } + n += fastpb.SizeString(1, x.GetBaseTypeName()) + return n +} + +func (x *ExtensionNumberResponse) sizeField2() (n int) { + if len(x.ExtensionNumber) == 0 { + return n + } + n += fastpb.SizeListPacked(2, len(x.GetExtensionNumber()), + func(numTagOrKey, numIdxOrVal int32) int { + n := 0 + n += fastpb.SizeInt32(numTagOrKey, x.GetExtensionNumber()[numIdxOrVal]) + return n + }) + return n +} + +func (x *ListServiceResponse) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *ListServiceResponse) sizeField1() (n int) { + if x.Service == nil { + return n + } + for i := range x.GetService() { + n += fastpb.SizeMessage(1, x.GetService()[i]) + } + return n +} + +func (x *ServiceResponse) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *ServiceResponse) sizeField1() (n int) { + if x.Name == "" { + return n + } + n += fastpb.SizeString(1, x.GetName()) + return n +} + +func (x *ErrorResponse) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField2() + return n +} + +func (x *ErrorResponse) sizeField1() (n int) { + if x.ErrorCode == 0 { + return n + } + n += fastpb.SizeInt32(1, x.GetErrorCode()) + return n +} + +func (x *ErrorResponse) sizeField2() (n int) { + if x.ErrorMessage == "" { + return n + } + n += fastpb.SizeString(2, x.GetErrorMessage()) + return n +} + +var fieldIDToName_ServerReflectionRequest = map[int32]string{ + 1: "Host", + 3: "FileByFilename", + 4: "FileContainingSymbol", + 5: "FileContainingExtension", + 6: "AllExtensionNumbersOfType", + 7: "ListServices", +} + +var fieldIDToName_ExtensionRequest = map[int32]string{ + 1: "ContainingType", + 2: "ExtensionNumber", +} + +var fieldIDToName_ServerReflectionResponse = map[int32]string{ + 1: "ValidHost", + 2: "OriginalRequest", + 4: "FileDescriptorResponse", + 5: "AllExtensionNumbersResponse", + 6: "ListServicesResponse", + 7: "ErrorResponse", +} + +var fieldIDToName_FileDescriptorResponse = map[int32]string{ + 1: "FileDescriptorProto", +} + +var fieldIDToName_ExtensionNumberResponse = map[int32]string{ + 1: "BaseTypeName", + 2: "ExtensionNumber", +} + +var fieldIDToName_ListServiceResponse = map[int32]string{ + 1: "Service", +} + +var fieldIDToName_ServiceResponse = map[int32]string{ + 1: "Name", +} + +var fieldIDToName_ErrorResponse = map[int32]string{ + 1: "ErrorCode", + 2: "ErrorMessage", +} diff --git a/pkg/reflection/grpc/reflection/v1alpha/reflection.pb.go b/pkg/reflection/grpc/reflection/v1alpha/reflection.pb.go new file mode 100644 index 0000000000..257f5a7b37 --- /dev/null +++ b/pkg/reflection/grpc/reflection/v1alpha/reflection.pb.go @@ -0,0 +1,972 @@ +/* + * Copyright 2024 CloudWeGo 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. + */ + +// Warning: this entire file is deprecated. Use this instead: +// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v5.26.1 +// grpc/reflection/v1alpha/reflection.proto is a deprecated file. + +package v1alpha + +import ( + context "context" + streaming "github.com/cloudwego/kitex/pkg/streaming" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// The message sent by the client when calling ServerReflectionInfo method. +type ServerReflectionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Host string `protobuf:"bytes,1,opt,name=host,proto3" 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 assignable to MessageRequest: + // + // *ServerReflectionRequest_FileByFilename + // *ServerReflectionRequest_FileContainingSymbol + // *ServerReflectionRequest_FileContainingExtension + // *ServerReflectionRequest_AllExtensionNumbersOfType + // *ServerReflectionRequest_ListServices + MessageRequest isServerReflectionRequest_MessageRequest `protobuf_oneof:"message_request"` +} + +func (x *ServerReflectionRequest) Reset() { + *x = ServerReflectionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServerReflectionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerReflectionRequest) ProtoMessage() {} + +func (x *ServerReflectionRequest) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerReflectionRequest.ProtoReflect.Descriptor instead. +func (*ServerReflectionRequest) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{0} +} + +func (x *ServerReflectionRequest) GetHost() string { + if x != nil { + return x.Host + } + return "" +} + +func (m *ServerReflectionRequest) GetMessageRequest() isServerReflectionRequest_MessageRequest { + if m != nil { + return m.MessageRequest + } + return nil +} + +func (x *ServerReflectionRequest) GetFileByFilename() string { + if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileByFilename); ok { + return x.FileByFilename + } + return "" +} + +func (x *ServerReflectionRequest) GetFileContainingSymbol() string { + if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileContainingSymbol); ok { + return x.FileContainingSymbol + } + return "" +} + +func (x *ServerReflectionRequest) GetFileContainingExtension() *ExtensionRequest { + if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileContainingExtension); ok { + return x.FileContainingExtension + } + return nil +} + +func (x *ServerReflectionRequest) GetAllExtensionNumbersOfType() string { + if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_AllExtensionNumbersOfType); ok { + return x.AllExtensionNumbersOfType + } + return "" +} + +func (x *ServerReflectionRequest) GetListServices() string { + if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_ListServices); ok { + return x.ListServices + } + return "" +} + +type isServerReflectionRequest_MessageRequest interface { + isServerReflectionRequest_MessageRequest() +} + +type ServerReflectionRequest_FileByFilename struct { + // Find a proto file by the file name. + FileByFilename string `protobuf:"bytes,3,opt,name=file_by_filename,json=fileByFilename,proto3,oneof"` +} + +type ServerReflectionRequest_FileContainingSymbol struct { + // Find the proto file that declares the given fully-qualified symbol name. + // This field should be a fully-qualified symbol name + // (e.g. .[.] or .). + FileContainingSymbol string `protobuf:"bytes,4,opt,name=file_containing_symbol,json=fileContainingSymbol,proto3,oneof"` +} + +type ServerReflectionRequest_FileContainingExtension struct { + // Find the proto file which defines an extension extending the given + // message type with the given field number. + FileContainingExtension *ExtensionRequest `protobuf:"bytes,5,opt,name=file_containing_extension,json=fileContainingExtension,proto3,oneof"` +} + +type ServerReflectionRequest_AllExtensionNumbersOfType struct { + // 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 + // . + AllExtensionNumbersOfType string `protobuf:"bytes,6,opt,name=all_extension_numbers_of_type,json=allExtensionNumbersOfType,proto3,oneof"` +} + +type ServerReflectionRequest_ListServices struct { + // List the full names of registered services. The content will not be + // checked. + ListServices string `protobuf:"bytes,7,opt,name=list_services,json=listServices,proto3,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() {} + +// The type name and extension number sent by the client when requesting +// file_containing_extension. +type ExtensionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Fully-qualified type name. The format should be . + ContainingType string `protobuf:"bytes,1,opt,name=containing_type,json=containingType,proto3" json:"containing_type,omitempty"` + ExtensionNumber int32 `protobuf:"varint,2,opt,name=extension_number,json=extensionNumber,proto3" json:"extension_number,omitempty"` +} + +func (x *ExtensionRequest) Reset() { + *x = ExtensionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ExtensionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExtensionRequest) ProtoMessage() {} + +func (x *ExtensionRequest) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExtensionRequest.ProtoReflect.Descriptor instead. +func (*ExtensionRequest) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{1} +} + +func (x *ExtensionRequest) GetContainingType() string { + if x != nil { + return x.ContainingType + } + return "" +} + +func (x *ExtensionRequest) GetExtensionNumber() int32 { + if x != nil { + return x.ExtensionNumber + } + return 0 +} + +// The message sent by the server to answer ServerReflectionInfo method. +type ServerReflectionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ValidHost string `protobuf:"bytes,1,opt,name=valid_host,json=validHost,proto3" json:"valid_host,omitempty"` + OriginalRequest *ServerReflectionRequest `protobuf:"bytes,2,opt,name=original_request,json=originalRequest,proto3" json:"original_request,omitempty"` + // The server set one of the following fields according to the message_request + // in the request. + // + // Types that are assignable to MessageResponse: + // + // *ServerReflectionResponse_FileDescriptorResponse + // *ServerReflectionResponse_AllExtensionNumbersResponse + // *ServerReflectionResponse_ListServicesResponse + // *ServerReflectionResponse_ErrorResponse + MessageResponse isServerReflectionResponse_MessageResponse `protobuf_oneof:"message_response"` +} + +func (x *ServerReflectionResponse) Reset() { + *x = ServerReflectionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServerReflectionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerReflectionResponse) ProtoMessage() {} + +func (x *ServerReflectionResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerReflectionResponse.ProtoReflect.Descriptor instead. +func (*ServerReflectionResponse) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{2} +} + +func (x *ServerReflectionResponse) GetValidHost() string { + if x != nil { + return x.ValidHost + } + return "" +} + +func (x *ServerReflectionResponse) GetOriginalRequest() *ServerReflectionRequest { + if x != nil { + return x.OriginalRequest + } + return nil +} + +func (m *ServerReflectionResponse) GetMessageResponse() isServerReflectionResponse_MessageResponse { + if m != nil { + return m.MessageResponse + } + return nil +} + +func (x *ServerReflectionResponse) GetFileDescriptorResponse() *FileDescriptorResponse { + if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_FileDescriptorResponse); ok { + return x.FileDescriptorResponse + } + return nil +} + +func (x *ServerReflectionResponse) GetAllExtensionNumbersResponse() *ExtensionNumberResponse { + if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_AllExtensionNumbersResponse); ok { + return x.AllExtensionNumbersResponse + } + return nil +} + +func (x *ServerReflectionResponse) GetListServicesResponse() *ListServiceResponse { + if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_ListServicesResponse); ok { + return x.ListServicesResponse + } + return nil +} + +func (x *ServerReflectionResponse) GetErrorResponse() *ErrorResponse { + if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_ErrorResponse); ok { + return x.ErrorResponse + } + return nil +} + +type isServerReflectionResponse_MessageResponse interface { + isServerReflectionResponse_MessageResponse() +} + +type ServerReflectionResponse_FileDescriptorResponse struct { + // 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 *FileDescriptorResponse `protobuf:"bytes,4,opt,name=file_descriptor_response,json=fileDescriptorResponse,proto3,oneof"` +} + +type ServerReflectionResponse_AllExtensionNumbersResponse struct { + // This message is used to answer all_extension_numbers_of_type requst. + AllExtensionNumbersResponse *ExtensionNumberResponse `protobuf:"bytes,5,opt,name=all_extension_numbers_response,json=allExtensionNumbersResponse,proto3,oneof"` +} + +type ServerReflectionResponse_ListServicesResponse struct { + // This message is used to answer list_services request. + ListServicesResponse *ListServiceResponse `protobuf:"bytes,6,opt,name=list_services_response,json=listServicesResponse,proto3,oneof"` +} + +type ServerReflectionResponse_ErrorResponse struct { + // This message is used when an error occurs. + ErrorResponse *ErrorResponse `protobuf:"bytes,7,opt,name=error_response,json=errorResponse,proto3,oneof"` +} + +func (*ServerReflectionResponse_FileDescriptorResponse) isServerReflectionResponse_MessageResponse() { +} + +func (*ServerReflectionResponse_AllExtensionNumbersResponse) isServerReflectionResponse_MessageResponse() { +} + +func (*ServerReflectionResponse_ListServicesResponse) isServerReflectionResponse_MessageResponse() {} + +func (*ServerReflectionResponse_ErrorResponse) isServerReflectionResponse_MessageResponse() {} + +// Serialized FileDescriptorProto messages sent by the server answering +// a file_by_filename, file_containing_symbol, or file_containing_extension +// request. +type FileDescriptorResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 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 (x *FileDescriptorResponse) Reset() { + *x = FileDescriptorResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FileDescriptorResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FileDescriptorResponse) ProtoMessage() {} + +func (x *FileDescriptorResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FileDescriptorResponse.ProtoReflect.Descriptor instead. +func (*FileDescriptorResponse) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{3} +} + +func (x *FileDescriptorResponse) GetFileDescriptorProto() [][]byte { + if x != nil { + return x.FileDescriptorProto + } + return nil +} + +// A list of extension numbers sent by the server answering +// all_extension_numbers_of_type request. +type ExtensionNumberResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Full name of the base type, including the package name. The format + // is . + BaseTypeName string `protobuf:"bytes,1,opt,name=base_type_name,json=baseTypeName,proto3" json:"base_type_name,omitempty"` + ExtensionNumber []int32 `protobuf:"varint,2,rep,packed,name=extension_number,json=extensionNumber,proto3" json:"extension_number,omitempty"` +} + +func (x *ExtensionNumberResponse) Reset() { + *x = ExtensionNumberResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ExtensionNumberResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExtensionNumberResponse) ProtoMessage() {} + +func (x *ExtensionNumberResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExtensionNumberResponse.ProtoReflect.Descriptor instead. +func (*ExtensionNumberResponse) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{4} +} + +func (x *ExtensionNumberResponse) GetBaseTypeName() string { + if x != nil { + return x.BaseTypeName + } + return "" +} + +func (x *ExtensionNumberResponse) GetExtensionNumber() []int32 { + if x != nil { + return x.ExtensionNumber + } + return nil +} + +// A list of ServiceResponse sent by the server answering list_services request. +type ListServiceResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 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,proto3" json:"service,omitempty"` +} + +func (x *ListServiceResponse) Reset() { + *x = ListServiceResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListServiceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListServiceResponse) ProtoMessage() {} + +func (x *ListServiceResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListServiceResponse.ProtoReflect.Descriptor instead. +func (*ListServiceResponse) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{5} +} + +func (x *ListServiceResponse) GetService() []*ServiceResponse { + if x != nil { + return x.Service + } + return nil +} + +// The information of a single service used by ListServiceResponse to answer +// list_services request. +type ServiceResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Full name of a registered service, including its package name. The format + // is . + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *ServiceResponse) Reset() { + *x = ServiceResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServiceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServiceResponse) ProtoMessage() {} + +func (x *ServiceResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServiceResponse.ProtoReflect.Descriptor instead. +func (*ServiceResponse) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{6} +} + +func (x *ServiceResponse) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// The error code and error message sent by the server when an error occurs. +type ErrorResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // This field uses the error codes defined in grpc::StatusCode. + ErrorCode int32 `protobuf:"varint,1,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"` + ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` +} + +func (x *ErrorResponse) Reset() { + *x = ErrorResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ErrorResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ErrorResponse) ProtoMessage() {} + +func (x *ErrorResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ErrorResponse.ProtoReflect.Descriptor instead. +func (*ErrorResponse) Descriptor() ([]byte, []int) { + return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{7} +} + +func (x *ErrorResponse) GetErrorCode() int32 { + if x != nil { + return x.ErrorCode + } + return 0 +} + +func (x *ErrorResponse) GetErrorMessage() string { + if x != nil { + return x.ErrorMessage + } + return "" +} + +var File_grpc_reflection_v1alpha_reflection_proto protoreflect.FileDescriptor + +var file_grpc_reflection_v1alpha_reflection_proto_rawDesc = []byte{ + 0x0a, 0x28, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x67, 0x72, 0x70, 0x63, + 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x22, 0xf8, 0x02, 0x0a, 0x17, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, + 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, + 0x6f, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x62, 0x79, 0x5f, 0x66, + 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, + 0x0e, 0x66, 0x69, 0x6c, 0x65, 0x42, 0x79, 0x46, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x36, 0x0a, 0x16, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, + 0x6e, 0x67, 0x5f, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, + 0x00, 0x52, 0x14, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, + 0x67, 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x12, 0x67, 0x0a, 0x19, 0x66, 0x69, 0x6c, 0x65, 0x5f, + 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x67, 0x72, 0x70, + 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x17, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, + 0x12, 0x42, 0x0a, 0x1d, 0x61, 0x6c, 0x6c, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x74, 0x79, 0x70, + 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x19, 0x61, 0x6c, 0x6c, 0x45, 0x78, + 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x4f, 0x66, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x0d, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0c, 0x6c, + 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x42, 0x11, 0x0a, 0x0f, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x66, + 0x0a, 0x10, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, + 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x65, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, + 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0xc7, 0x04, 0x0a, 0x18, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x5f, 0x68, 0x6f, 0x73, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x48, 0x6f, + 0x73, 0x74, 0x12, 0x5b, 0x0a, 0x10, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, + 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, + 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0f, + 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x6b, 0x0a, 0x18, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x46, 0x69, 0x6c, 0x65, + 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x48, 0x00, 0x52, 0x16, 0x66, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x77, 0x0a, 0x1e, + 0x61, 0x6c, 0x6c, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x45, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x1b, 0x61, 0x6c, 0x6c, 0x45, 0x78, 0x74, + 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x64, 0x0a, 0x16, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, + 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, + 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x14, 0x6c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x0e, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x0d, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x12, 0x0a, 0x10, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x4c, 0x0a, 0x16, 0x46, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x15, 0x66, 0x69, + 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x5f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x13, 0x66, 0x69, 0x6c, 0x65, 0x44, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6a, + 0x0a, 0x17, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x62, 0x61, 0x73, + 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x62, 0x61, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x29, 0x0a, 0x10, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05, 0x52, 0x0f, 0x65, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x59, 0x0a, 0x13, 0x4c, 0x69, + 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x42, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x07, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x25, 0x0a, 0x0f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x53, 0x0a, 0x0d, + 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, + 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x0d, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x32, 0x93, 0x01, 0x0a, 0x10, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x7f, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x30, + 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, + 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x42, 0x7b, 0x0a, 0x1a, 0x69, 0x6f, 0x2e, 0x67, 0x72, + 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x42, 0x15, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, + 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x41, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, + 0x77, 0x65, 0x67, 0x6f, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, + 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x72, + 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0xb8, 0x01, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_grpc_reflection_v1alpha_reflection_proto_rawDescOnce sync.Once + file_grpc_reflection_v1alpha_reflection_proto_rawDescData = file_grpc_reflection_v1alpha_reflection_proto_rawDesc +) + +func file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP() []byte { + file_grpc_reflection_v1alpha_reflection_proto_rawDescOnce.Do(func() { + file_grpc_reflection_v1alpha_reflection_proto_rawDescData = protoimpl.X.CompressGZIP(file_grpc_reflection_v1alpha_reflection_proto_rawDescData) + }) + return file_grpc_reflection_v1alpha_reflection_proto_rawDescData +} + +var file_grpc_reflection_v1alpha_reflection_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_grpc_reflection_v1alpha_reflection_proto_goTypes = []interface{}{ + (*ServerReflectionRequest)(nil), // 0: grpc.reflection.v1alpha.ServerReflectionRequest + (*ExtensionRequest)(nil), // 1: grpc.reflection.v1alpha.ExtensionRequest + (*ServerReflectionResponse)(nil), // 2: grpc.reflection.v1alpha.ServerReflectionResponse + (*FileDescriptorResponse)(nil), // 3: grpc.reflection.v1alpha.FileDescriptorResponse + (*ExtensionNumberResponse)(nil), // 4: grpc.reflection.v1alpha.ExtensionNumberResponse + (*ListServiceResponse)(nil), // 5: grpc.reflection.v1alpha.ListServiceResponse + (*ServiceResponse)(nil), // 6: grpc.reflection.v1alpha.ServiceResponse + (*ErrorResponse)(nil), // 7: grpc.reflection.v1alpha.ErrorResponse +} +var file_grpc_reflection_v1alpha_reflection_proto_depIdxs = []int32{ + 1, // 0: grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_extension:type_name -> grpc.reflection.v1alpha.ExtensionRequest + 0, // 1: grpc.reflection.v1alpha.ServerReflectionResponse.original_request:type_name -> grpc.reflection.v1alpha.ServerReflectionRequest + 3, // 2: grpc.reflection.v1alpha.ServerReflectionResponse.file_descriptor_response:type_name -> grpc.reflection.v1alpha.FileDescriptorResponse + 4, // 3: grpc.reflection.v1alpha.ServerReflectionResponse.all_extension_numbers_response:type_name -> grpc.reflection.v1alpha.ExtensionNumberResponse + 5, // 4: grpc.reflection.v1alpha.ServerReflectionResponse.list_services_response:type_name -> grpc.reflection.v1alpha.ListServiceResponse + 7, // 5: grpc.reflection.v1alpha.ServerReflectionResponse.error_response:type_name -> grpc.reflection.v1alpha.ErrorResponse + 6, // 6: grpc.reflection.v1alpha.ListServiceResponse.service:type_name -> grpc.reflection.v1alpha.ServiceResponse + 0, // 7: grpc.reflection.v1alpha.ServerReflection.ServerReflectionInfo:input_type -> grpc.reflection.v1alpha.ServerReflectionRequest + 2, // 8: grpc.reflection.v1alpha.ServerReflection.ServerReflectionInfo:output_type -> grpc.reflection.v1alpha.ServerReflectionResponse + 8, // [8:9] is the sub-list for method output_type + 7, // [7:8] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_grpc_reflection_v1alpha_reflection_proto_init() } +func file_grpc_reflection_v1alpha_reflection_proto_init() { + if File_grpc_reflection_v1alpha_reflection_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_grpc_reflection_v1alpha_reflection_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServerReflectionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1alpha_reflection_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ExtensionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1alpha_reflection_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServerReflectionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1alpha_reflection_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FileDescriptorResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1alpha_reflection_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ExtensionNumberResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1alpha_reflection_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListServiceResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1alpha_reflection_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServiceResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_reflection_v1alpha_reflection_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ErrorResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_grpc_reflection_v1alpha_reflection_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*ServerReflectionRequest_FileByFilename)(nil), + (*ServerReflectionRequest_FileContainingSymbol)(nil), + (*ServerReflectionRequest_FileContainingExtension)(nil), + (*ServerReflectionRequest_AllExtensionNumbersOfType)(nil), + (*ServerReflectionRequest_ListServices)(nil), + } + file_grpc_reflection_v1alpha_reflection_proto_msgTypes[2].OneofWrappers = []interface{}{ + (*ServerReflectionResponse_FileDescriptorResponse)(nil), + (*ServerReflectionResponse_AllExtensionNumbersResponse)(nil), + (*ServerReflectionResponse_ListServicesResponse)(nil), + (*ServerReflectionResponse_ErrorResponse)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_grpc_reflection_v1alpha_reflection_proto_rawDesc, + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_grpc_reflection_v1alpha_reflection_proto_goTypes, + DependencyIndexes: file_grpc_reflection_v1alpha_reflection_proto_depIdxs, + MessageInfos: file_grpc_reflection_v1alpha_reflection_proto_msgTypes, + }.Build() + File_grpc_reflection_v1alpha_reflection_proto = out.File + file_grpc_reflection_v1alpha_reflection_proto_rawDesc = nil + file_grpc_reflection_v1alpha_reflection_proto_goTypes = nil + file_grpc_reflection_v1alpha_reflection_proto_depIdxs = nil +} + +var _ context.Context + +// Code generated by Kitex v0.9.1. DO NOT EDIT. + +type ServerReflection interface { + ServerReflectionInfo(stream ServerReflection_ServerReflectionInfoServer) (err error) +} + +type ServerReflection_ServerReflectionInfoServer interface { + streaming.Stream + Recv() (*ServerReflectionRequest, error) + Send(*ServerReflectionResponse) error +} diff --git a/pkg/reflection/grpc/reflection/v1alpha/reflection.proto b/pkg/reflection/grpc/reflection/v1alpha/reflection.proto new file mode 100644 index 0000000000..2756c339f7 --- /dev/null +++ b/pkg/reflection/grpc/reflection/v1alpha/reflection.proto @@ -0,0 +1,145 @@ +// Copyright 2016 The 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 + + +// Warning: this entire file is deprecated. Use this instead: +// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto + +syntax = "proto3"; + +package grpc.reflection.v1alpha; + +option deprecated = true; +option go_package = "grpc/reflection/v1alpha"; +option java_multiple_files = true; +option java_package = "io.grpc.reflection.v1alpha"; +option java_outer_classname = "ServerReflectionProto"; + +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. .[.] or .). + 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 + // . + 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 . + 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 . + 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 . + 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; +} \ No newline at end of file diff --git a/pkg/reflection/grpc/reflection/v1alpha/serverreflection/client.go b/pkg/reflection/grpc/reflection/v1alpha/serverreflection/client.go new file mode 100644 index 0000000000..9210174623 --- /dev/null +++ b/pkg/reflection/grpc/reflection/v1alpha/serverreflection/client.go @@ -0,0 +1,117 @@ +/* + * Copyright 2024 CloudWeGo 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. + */ + +// Code generated by Kitex v0.9.1. DO NOT EDIT. + +package serverreflection + +import ( + "context" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + v1alpha "github.com/cloudwego/kitex/pkg/reflection/grpc/reflection/v1alpha" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" + "github.com/cloudwego/kitex/client/streamclient" + "github.com/cloudwego/kitex/client/callopt/streamcall" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + ServerReflectionInfo(ctx context.Context, callOptions ...callopt.Option) (stream ServerReflection_ServerReflectionInfoClient, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + ServerReflectionInfo(ctx context.Context, callOptions ...streamcall.Option) (stream ServerReflection_ServerReflectionInfoClient, err error) +} + +type ServerReflection_ServerReflectionInfoClient interface { + streaming.Stream + Send(*v1alpha.ServerReflectionRequest) error + Recv() (*v1alpha.ServerReflectionResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, client.WithTransportProtocol(transport.GRPC)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kServerReflectionClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kServerReflectionClient struct { + *kClient +} + +func (p *kServerReflectionClient) ServerReflectionInfo(ctx context.Context, callOptions ...callopt.Option) (stream ServerReflection_ServerReflectionInfoClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.ServerReflectionInfo(ctx) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kServerReflectionStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kServerReflectionStreamClient struct { + *kClient +} + +func (p *kServerReflectionStreamClient) ServerReflectionInfo(ctx context.Context, callOptions ...streamcall.Option) (stream ServerReflection_ServerReflectionInfoClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.ServerReflectionInfo(ctx) +} diff --git a/pkg/reflection/grpc/reflection/v1alpha/serverreflection/serverreflection.go b/pkg/reflection/grpc/reflection/v1alpha/serverreflection/serverreflection.go new file mode 100644 index 0000000000..f8029bebf3 --- /dev/null +++ b/pkg/reflection/grpc/reflection/v1alpha/serverreflection/serverreflection.go @@ -0,0 +1,300 @@ +/* + * Copyright 2024 CloudWeGo 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. + */ + +// Code generated by Kitex v0.9.1. DO NOT EDIT. + +package serverreflection + +import ( + "context" + "errors" + "fmt" + client "github.com/cloudwego/kitex/client" + v1alpha "github.com/cloudwego/kitex/pkg/reflection/grpc/reflection/v1alpha" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" + proto "google.golang.org/protobuf/proto" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "ServerReflectionInfo": kitex.NewMethodInfo( + serverReflectionInfoHandler, + newServerReflectionInfoArgs, + newServerReflectionInfoResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + serverReflectionServiceInfo = NewServiceInfo() + serverReflectionServiceInfoForClient = NewServiceInfoForClient() + serverReflectionServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return serverReflectionServiceInfo +} + +// for stream client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return serverReflectionServiceInfoForStreamClient +} + +// for client +func serviceInfoForClient() *kitex.ServiceInfo { + return serverReflectionServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "ServerReflection" + handlerType := (*v1alpha.ServerReflection)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "grpc.reflection.v1alpha", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Protobuf, + KiteXGenVersion: "v0.9.1", + Extra: extra, + } + return svcInfo +} + +func serverReflectionInfoHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + streamingArgs, ok := arg.(*streaming.Args) + if !ok { + return errInvalidMessageType + } + st := streamingArgs.Stream + stream := &serverReflectionServerReflectionInfoServer{st} + return handler.(v1alpha.ServerReflection).ServerReflectionInfo(stream) +} + +type serverReflectionServerReflectionInfoClient struct { + streaming.Stream +} + +func (x *serverReflectionServerReflectionInfoClient) DoFinish(err error) { + if finisher, ok := x.Stream.(streaming.WithDoFinish); ok { + finisher.DoFinish(err) + } else { + panic(fmt.Sprintf("streaming.WithDoFinish is not implemented by %T", x.Stream)) + } +} +func (x *serverReflectionServerReflectionInfoClient) Send(m *v1alpha.ServerReflectionRequest) error { + return x.Stream.SendMsg(m) +} +func (x *serverReflectionServerReflectionInfoClient) Recv() (*v1alpha.ServerReflectionResponse, error) { + m := new(v1alpha.ServerReflectionResponse) + return m, x.Stream.RecvMsg(m) +} + +type serverReflectionServerReflectionInfoServer struct { + streaming.Stream +} + +func (x *serverReflectionServerReflectionInfoServer) Send(m *v1alpha.ServerReflectionResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *serverReflectionServerReflectionInfoServer) Recv() (*v1alpha.ServerReflectionRequest, error) { + m := new(v1alpha.ServerReflectionRequest) + return m, x.Stream.RecvMsg(m) +} + +func newServerReflectionInfoArgs() interface{} { + return &ServerReflectionInfoArgs{} +} + +func newServerReflectionInfoResult() interface{} { + return &ServerReflectionInfoResult{} +} + +type ServerReflectionInfoArgs struct { + Req *v1alpha.ServerReflectionRequest +} + +func (p *ServerReflectionInfoArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetReq() { + p.Req = new(v1alpha.ServerReflectionRequest) + } + return p.Req.FastRead(buf, _type, number) +} + +func (p *ServerReflectionInfoArgs) FastWrite(buf []byte) (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.FastWrite(buf) +} + +func (p *ServerReflectionInfoArgs) Size() (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.Size() +} + +func (p *ServerReflectionInfoArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, nil + } + return proto.Marshal(p.Req) +} + +func (p *ServerReflectionInfoArgs) Unmarshal(in []byte) error { + msg := new(v1alpha.ServerReflectionRequest) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var ServerReflectionInfoArgs_Req_DEFAULT *v1alpha.ServerReflectionRequest + +func (p *ServerReflectionInfoArgs) GetReq() *v1alpha.ServerReflectionRequest { + if !p.IsSetReq() { + return ServerReflectionInfoArgs_Req_DEFAULT + } + return p.Req +} + +func (p *ServerReflectionInfoArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *ServerReflectionInfoArgs) GetFirstArgument() interface{} { + return p.Req +} + +type ServerReflectionInfoResult struct { + Success *v1alpha.ServerReflectionResponse +} + +var ServerReflectionInfoResult_Success_DEFAULT *v1alpha.ServerReflectionResponse + +func (p *ServerReflectionInfoResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetSuccess() { + p.Success = new(v1alpha.ServerReflectionResponse) + } + return p.Success.FastRead(buf, _type, number) +} + +func (p *ServerReflectionInfoResult) FastWrite(buf []byte) (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.FastWrite(buf) +} + +func (p *ServerReflectionInfoResult) Size() (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.Size() +} + +func (p *ServerReflectionInfoResult) Marshal(out []byte) ([]byte, error) { + if !p.IsSetSuccess() { + return out, nil + } + return proto.Marshal(p.Success) +} + +func (p *ServerReflectionInfoResult) Unmarshal(in []byte) error { + msg := new(v1alpha.ServerReflectionResponse) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Success = msg + return nil +} + +func (p *ServerReflectionInfoResult) GetSuccess() *v1alpha.ServerReflectionResponse { + if !p.IsSetSuccess() { + return ServerReflectionInfoResult_Success_DEFAULT + } + return p.Success +} + +func (p *ServerReflectionInfoResult) SetSuccess(x interface{}) { + p.Success = x.(*v1alpha.ServerReflectionResponse) +} + +func (p *ServerReflectionInfoResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ServerReflectionInfoResult) GetResult() interface{} { + return p.Success +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) ServerReflectionInfo(ctx context.Context) (ServerReflection_ServerReflectionInfoClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "ServerReflectionInfo", nil, res) + if err != nil { + return nil, err + } + stream := &serverReflectionServerReflectionInfoClient{res.Stream} + return stream, nil +} diff --git a/server/option.go b/server/option.go index 59e587d7cd..a0933ff439 100644 --- a/server/option.go +++ b/server/option.go @@ -19,6 +19,7 @@ package server import ( "context" "fmt" + "github.com/cloudwego/kitex/transport" "net" "time" @@ -389,3 +390,11 @@ func WithEnableContextTimeout(enable bool) Option { o.EnableContextTimeout = enable }} } + +func WithReflectionServer(prot transport.Protocol) Option { + return Option{F: func(o *internal_server.Options, di *utils.Slice) { + if prot|transport.GRPC == transport.GRPC { + o.EnableGrpcReflection = true + } + }} +} diff --git a/server/server.go b/server/server.go index 07027ede9e..f8ffcd59d2 100644 --- a/server/server.go +++ b/server/server.go @@ -21,6 +21,7 @@ import ( "context" "errors" "fmt" + "github.com/cloudwego/kitex/pkg/reflection/grpc" "net" "reflect" "runtime/debug" @@ -199,6 +200,18 @@ func (s *server) RegisterService(svcInfo *serviceinfo.ServiceInfo, handler inter return nil } +func (s *server) registerReflectionService() { + registerOpts := internal_server.NewRegisterOptions(nil) + // register v1 reflection service + if err := s.svcs.addService(grpc.NewV1ServiceInfo(), grpc.NewV1Handler(s.svcs.getSvcInfoMap()), registerOpts); err != nil { + panic(err.Error()) + } + // register v1alpha reflection service + if err := s.svcs.addService(grpc.NewV1AlphaServiceInfo(), grpc.NewV1alphaHandler(s.svcs.getSvcInfoMap()), registerOpts); err != nil { + panic(err.Error()) + } +} + func (s *server) GetServiceInfos() map[string]*serviceinfo.ServiceInfo { return s.svcs.getSvcInfoSearchMap() } @@ -225,6 +238,7 @@ func (s *server) Run() (err error) { } } + s.registerReflectionService() s.fillMoreServiceInfo(s.opt.RemoteOpt.Address) s.richRemoteOption() transHdlr, err := s.newSvrTransHandler()