grpcreflect

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package grpcreflect provides GRPC-specific extensions to protobuf reflection. This includes a way to access rich service descriptors for all services that a GRPC server exports.

Also included is an easy-to-use client for the GRPC reflection service (https://goo.gl/2ILAHf). This client makes it easy to ask a server (that supports the reflection service) for metadata on its exported services, which could be used to construct a dynamic client. (See the grpcdynamic package in this same repo for more on that.)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsElementNotFoundError

func IsElementNotFoundError(err error) bool

IsElementNotFoundError determines if the given error indicates that a file name, symbol name, or extension field was could not be found by the server.

func LoadServiceDescriptor

func LoadServiceDescriptor(svc *grpc.ServiceDesc) (*desc.ServiceDescriptor, error)

LoadServiceDescriptor loads a rich descriptor for a given service description generated by protoc-gen-go. Generated code contains an unexported symbol with a name like "_<Service>_serviceDesc" which is the service's description. It is used internally to register a service implementation with a GRPC server. But it can also be used by this package to retrieve the rich descriptor for the service.

func LoadServiceDescriptors

func LoadServiceDescriptors(s *grpc.Server) (map[string]*desc.ServiceDescriptor, error)

LoadServiceDescriptors loads the service descriptors for all services exposed by the given GRPC server.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client connection to a server for performing reflection calls and resolving remote symbols.

func NewClient

func NewClient(ctx context.Context, stub rpb.ServerReflectionClient) *Client

NewClient creates a new Client with the given root context and using the given RPC stub for talking to the server.

func (*Client) AllExtensionNumbersForType

func (cr *Client) AllExtensionNumbersForType(extendedMessageName string) ([]int32, error)

AllExtensionNumbersForType asks the server for all known extension numbers for the given fully-qualified message name.

func (*Client) FileByFilename

func (cr *Client) FileByFilename(filename string) (*desc.FileDescriptor, error)

FileByFilename asks the server for a file descriptor for the proto file with the given name.

func (*Client) FileContainingExtension

func (cr *Client) FileContainingExtension(extendedMessageName string, extensionNumber int32) (*desc.FileDescriptor, error)

FileContainingExtension asks the server for a file descriptor for the proto file that declares an extension with the given number for the given fully-qualified message name.

func (*Client) FileContainingSymbol

func (cr *Client) FileContainingSymbol(symbol string) (*desc.FileDescriptor, error)

FileContainingSymbol asks the server for a file descriptor for the proto file that declares the given fully-qualified symbol.

func (*Client) ListServices

func (cr *Client) ListServices() ([]string, error)

ListServices asks the server for the fully-qualified names of all exposed services.

func (*Client) Reset

func (cr *Client) Reset()

Reset ensures that any active stream with the server is closed, releasing any resources.

func (*Client) ResolveEnum

func (cr *Client) ResolveEnum(enumName string) (*desc.EnumDescriptor, error)

ResolveEnum asks the server to resolve the given fully-qualified enum name into an enum descriptor.

func (*Client) ResolveEnumValues

func (cr *Client) ResolveEnumValues(enumName string) (map[string]int32, error)

ResolveEnumValues asks the server to resolve the given fully-qualified enum name into a map of names to numbers that represents the enum's values.

func (*Client) ResolveExtension

func (cr *Client) ResolveExtension(extendedType string, extensionNumber int32) (*desc.FieldDescriptor, error)

ResolveExtension asks the server to resolve the given extension number and fully-qualified message name into a field descriptor.

func (*Client) ResolveMessage

func (cr *Client) ResolveMessage(messageName string) (*desc.MessageDescriptor, error)

ResolveMessage asks the server to resolve the given fully-qualified message name into a message descriptor.

func (*Client) ResolveService

func (cr *Client) ResolveService(serviceName string) (*desc.ServiceDescriptor, error)

ResolveService asks the server to resolve the given fully-qualified service name into a service descriptor.

type ProtocolError

type ProtocolError struct {
	// contains filtered or unexported fields
}

ProtocolError is an error returned when the server sends a response of the wrong type.

func (ProtocolError) Error

func (p ProtocolError) Error() string

Jump to

Keyboard shortcuts

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