connectrpc / grpcreflect-go Goto Github PK
View Code? Open in Web Editor NEWgRPC-compatible server reflection for any net/http server.
Home Page: https://connectrpc.com
License: Apache License 2.0
gRPC-compatible server reflection for any net/http server.
Home Page: https://connectrpc.com
License: Apache License 2.0
Hi guys, thanks for the awesome tool.
However, i'm facing this problem when using grpcreflect with connect-go.
WARNING: proto: file "connectext/grpc/status/v1/status.proto" is already registered
previously from: "connectrpc.com/connect/internal/gen/connectext/grpc/status/v1"
currently from: "github.com/bufbuild/connect-go/internal/gen/connectext/grpc/status/v1"
The problem can be resolved if i add -ldflags "-X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn"
to go run and go build command.
Is there any better way to resolve this problem ?
My version from go.mod
connectrpc.com/grpcreflect v1.2.0
github.com/bufbuild/connect-go v1.10.0
Trying to create a client that uses connect-go
to communicate with a server that supports gRPC reflection is rather a hassle. Each such usage must use custom code generation (like this repo does) to avoid adding a dependency on google.golang.org/grpc/reflection
(which would transitively bring in all of gRPC 😭). Given the name of this repo, it seems within bounds for this repo to provide that.
I know the API would want to avoid exposing the generated base types, for aesthetic reasons, but I don't think that's a very big lift. The only real question IMO is whether to drop it in the main grpcreflect
package or to add a grpcreflectclient
sub-package.
WDYT?
Re: ripping out makego. Not a high priority.
grpcurl list and grpcurl describe both work, but the grpcui throws error
grpcui -plaintext localhost:8080
Failed to compute set of methods to expose: server does not support the reflection API
The grpcurl works
grpcurl -plaintext localhost:8080 list
api.v1.APIService
grpcurl -plaintext localhost:8080 describe
api.v1.APIService is a service:
service APIService {
....omitted....
}
version info
$ grpcui --version
grpcui 1.4.1
$ grpcurl --version
grpcurl dev build <no version set>
reflection error comes up with postman as well.
In this PR for UI, support for describing protobuf entities has been implemented.
This works well if you use local .proto
.
grpcui -proto test.proto -plaintext localhost:8080
description: "// test comment\noptional int64 test_id = 1;\n"
But when using grpcreflect-go, comments do not appear in the description line
description: "optional int64 test_id = 1;\n"
May I submit a pull request?
When using connect-grpcreflect-go v1.0.0, ErrorDetail is not displayed when an error occurs in response to a request from the client.
This problem does not occur when using google.golang.org/grpc v1.51.0.
https://github.com/2yanpath/grpc-error-detail-test
% grpcurl -plaintext -d '{"name": ""}' localhost:8081 greet.v1.GreetService.Greet
ERROR:
Code: InvalidArgument
Message: name is required
Details:
1) {"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"username","description":"should not empty"}]}
Expected respone
https://github.com/2yanpath/connect-error-detail-test
branch: main
% grpcurl -plaintext -d '{"name": ""}' localhost:8082 greet.v1.GreetService.Greet
ERROR:
Code: InvalidArgument
Message: name is required
Details:
1) {"@error":"google.rpc.BadRequest is not recognized; see @value for raw binary message data","@type":"type.googleapis.com/google.rpc.BadRequest","@value":"ChwKCHVzZXJuYW1lEhBzaG91bGQgbm90IGVtcHR5"}
problem: ErrorDetail cannot be displayed.
https://github.com/2yanpath/connect-error-detail-test
branch: fix/error-detail
% grpcurl -plaintext -d '{"name": ""}' localhost:8082 greet.v1.GreetService.Greet
ERROR:
Code: InvalidArgument
Message: name is required
Details:
1) {"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"username","description":"should not empty"}]}
// allExtensionNumbersForTypeName returns all extension numbers for the given type.
func (s *serverReflectionServer) 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 {
//-- NOTICE no error is thrown, so ([]int32{}, nil) is returned
// 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
}
func (r *Reflector) getAllExtensionNumbersOfType(fqn string) ([]int32, error) {
nums := []int32{}
name := protoreflect.FullName(fqn)
r.extensionResolver.RangeExtensionsByMessage(name, func(ext protoreflect.ExtensionType) bool {
num := int32(ext.TypeDescriptor().Number())
nums = append(nums, num)
return true
})
if len(nums) == 0 {
//-- NOTICE an error occurs and (nil, [the error below]) is returned
return nil, fmt.Errorf("no extensions for type %q", fqn)
}
sort.Slice(nums, func(i, j int) bool {
return nums[i] < nums[j]
})
return nums, nil
}
func (r *Reflector) getAllExtensionNumbersOfType(fqn string) ([]int32, error) {
nums := []int32{}
name := protoreflect.FullName(fqn)
r.extensionResolver.RangeExtensionsByMessage(name, func(ext protoreflect.ExtensionType) bool {
num := int32(ext.TypeDescriptor().Number())
nums = append(nums, num)
return true
})
if len(nums) == 0 {
if _, err := r.descriptorResolver.FindDescriptorByName(name); err != nil {
return nil, err
}
}
sort.Slice(nums, func(i, j int) bool {
return nums[i] < nums[j]
})
return nums, nil
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.