reflection
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
README¶
Reflection
Package reflection implements server reflection service.
The service implemented is defined in:https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1/reflection.proto.
To register server reflection on a gRPC server:
import "google.golang.org/grpc/reflection"s := grpc.NewServer()pb.RegisterYourOwnServer(s, &server{})// Register reflection service on gRPC server.reflection.Register(s)s.Serve(lis)
Documentation¶
Overview¶
Package reflection implements server reflection service.
The service implemented is defined in:https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto.
To register server reflection on a gRPC server:
import "google.golang.org/grpc/reflection"s := grpc.NewServer()pb.RegisterYourOwnServer(s, &server{})// Register reflection service on gRPC server.reflection.Register(s)s.Serve(lis)Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcNewServer¶added inv1.45.0
func NewServer(optsServerOptions)v1alphareflectiongrpc.ServerReflectionServer
NewServer returns a reflection server implementation using the given options.This can be used to customize behavior of the reflection service. Most usagesshould prefer to use Register instead. For backwards compatibility reasons,this returns the v1alpha version of the reflection server. For a v1 versionof the reflection server, see NewServerV1.
Experimental¶
Notice: This function is EXPERIMENTAL and may be changed or removed in alater release.
funcNewServerV1¶added inv1.57.0
func NewServerV1(optsServerOptions)v1reflectiongrpc.ServerReflectionServer
NewServerV1 returns a reflection server implementation using the given options.This can be used to customize behavior of the reflection service. Most usagesshould prefer to use Register instead.
Experimental¶
Notice: This function is EXPERIMENTAL and may be changed or removed in alater release.
funcRegister¶
func Register(sGRPCServer)
Register registers the server reflection service on the given gRPC server.Both the v1 and v1alpha versions are registered.
funcRegisterV1¶added inv1.57.0
func RegisterV1(sGRPCServer)
RegisterV1 registers only the v1 version of the server reflection serviceon the given gRPC server. Many clients may only support v1alpha so mostusers should use Register instead, at least until clients have upgraded.
Types¶
typeExtensionResolver¶added inv1.45.0
type ExtensionResolver interface {protoregistry.ExtensionTypeResolverRangeExtensionsByMessage(messageprotoreflect.FullName, f func(protoreflect.ExtensionType)bool)}ExtensionResolver is the interface used to query details about extensions.This interface is satisfied by protoregistry.GlobalTypes.
Experimental¶
Notice: This type is EXPERIMENTAL and may be changed or removed in alater release.
typeGRPCServer¶added inv1.38.0
type GRPCServer interface {grpc.ServiceRegistrarServiceInfoProvider}GRPCServer is the interface provided by a gRPC server. It is implemented by*grpc.Server, but could also be implemented by other concrete types. It actsas a registry, for accumulating the services exposed by the server.
typeServerOptions¶added inv1.45.0
type ServerOptions struct {// The source of advertised RPC services. If not specified, the reflection// server will report an empty list when asked to list services.//// This value will typically be a *grpc.Server. But the set of advertised// services can be customized by wrapping a *grpc.Server or using an// alternate implementation that returns a custom set of service names.ServicesServiceInfoProvider// Optional resolver used to load descriptors. If not specified,// protoregistry.GlobalFiles will be used.DescriptorResolverprotodesc.Resolver// Optional resolver used to query for known extensions. If not specified,// protoregistry.GlobalTypes will be used.ExtensionResolverExtensionResolver}ServerOptions represents the options used to construct a reflection server.
Experimental¶
Notice: This type is EXPERIMENTAL and may be changed or removed in alater release.
typeServiceInfoProvider¶added inv1.45.0
type ServiceInfoProvider interface {GetServiceInfo() map[string]grpc.ServiceInfo}ServiceInfoProvider is an interface used to retrieve metadata about theservices to expose.
The reflection service is only interested in the service names, but thesignature is this way so that *grpc.Server implements it. So it is okayfor a custom implementation to return zero values for thegrpc.ServiceInfo values in the map.
Experimental¶
Notice: This type is EXPERIMENTAL and may be changed or removed in alater release.