reflection

package
v1.52.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2023 License: Apache-2.0 Imports: 10 Imported by: 9,274

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/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)

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

func NewServer added in v1.45.0

NewServer returns a reflection server implementation using the given options. This can be used to customize behavior of the reflection service. Most usages should prefer to use Register instead.

Experimental

Notice: This function is EXPERIMENTAL and may be changed or removed in a later release.

func Register

func Register(s GRPCServer)

Register registers the server reflection service on the given gRPC server.

Types

type ExtensionResolver added in v1.45.0

type ExtensionResolver interface {
	protoregistry.ExtensionTypeResolver
	RangeExtensionsByMessage(message protoreflect.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 a later release.

type GRPCServer added in v1.38.0

type GRPCServer interface {
	grpc.ServiceRegistrar
	ServiceInfoProvider
}

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 acts as a registry, for accumulating the services exposed by the server.

type ServerOptions added in v1.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.
	Services ServiceInfoProvider
	// Optional resolver used to load descriptors. If not specified,
	// protoregistry.GlobalFiles will be used.
	DescriptorResolver protodesc.Resolver
	// Optional resolver used to query for known extensions. If not specified,
	// protoregistry.GlobalTypes will be used.
	ExtensionResolver ExtensionResolver
}

ServerOptions represents the options used to construct a reflection server.

Experimental

Notice: This type is EXPERIMENTAL and may be changed or removed in a later release.

type ServiceInfoProvider added in v1.45.0

type ServiceInfoProvider interface {
	GetServiceInfo() map[string]grpc.ServiceInfo
}

ServiceInfoProvider is an interface used to retrieve metadata about the services to expose.

The reflection service is only interested in the service names, but the signature is this way so that *grpc.Server implements it. So it is okay for a custom implementation to return zero values for the grpc.ServiceInfo values in the map.

Experimental

Notice: This type is EXPERIMENTAL and may be changed or removed in a later release.

Directories

Path Synopsis
Package grpc_testing_not_regenerate is a generated protocol buffer package.
Package grpc_testing_not_regenerate is a generated protocol buffer package.
test module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL