reflection

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2021 License: MIT Imports: 19 Imported by: 0

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 Register

func Register(s *nrpc.Server)

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

Types

type Message

type Message interface {
	// MarshalJSON marshals the Message into JSON
	MarshalJSON() ([]byte, error)
	// UnmarshalJSON unmarshals JSON into a Message
	UnmarshalJSON(b []byte) error
	// ConvertFrom converts a raw protobuf message into a Message
	ConvertFrom(target proto.Message) error
	// AsProtoreflectMessage returns the underlying protoreflect message
	AsProtoreflectMessage() *dynamic.Message
}

Message is an simple abstraction of protobuf message

type MessageDescriptor

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

MessageDescriptor represents a message type

func (*MessageDescriptor) GetFullyQualifiedName

func (m *MessageDescriptor) GetFullyQualifiedName() string

GetFullyQualifiedName returns the fully qualified name of the underlying message

func (*MessageDescriptor) MakeTemplate

func (m *MessageDescriptor) MakeTemplate(descSource grpcurl.DescriptorSource) (string, error)

MakeTemplate makes a JSON template for this message, to make it easier to create a request to invoke an RPC

func (*MessageDescriptor) MakeTemplateMessage

func (m *MessageDescriptor) MakeTemplateMessage(descSource grpcurl.DescriptorSource) proto.Message

MakeTemplateMessage makes a message template for this message, to make it easier to create a request to invoke an RPC

func (*MessageDescriptor) NewMessage

func (m *MessageDescriptor) NewMessage() *messageImpl

NewMessage creates a new message from the message descriptor

type MethodDescriptor

type MethodDescriptor struct {
	*desc.MethodDescriptor
}

MethodDescriptor represents a method type

func (*MethodDescriptor) AsProtoreflectDescriptor

func (m *MethodDescriptor) AsProtoreflectDescriptor() *desc.MethodDescriptor

AsProtoreflectDescriptor returns the underlying protoreflect method descriptor

func (*MethodDescriptor) GetInputType

func (m *MethodDescriptor) GetInputType() *MessageDescriptor

GetInputType gets the MessageDescriptor for the method input type

func (*MethodDescriptor) GetName

func (m *MethodDescriptor) GetName() string

GetName returns the name of the method.

func (*MethodDescriptor) GetOutputType

func (m *MethodDescriptor) GetOutputType() *MessageDescriptor

GetOutputType gets the MessageDescriptor for the method output type

type MethodInvocation

type MethodInvocation struct {
	*MethodDescriptor
	Message
}

MethodInvocation contains a method and a message used to invoke an RPC

type Reflector

type Reflector interface {
	CreateInvocation(serviceName, methodName string, input []byte) (*MethodInvocation, error)
	ListServices() ([]string, error)
	DescribeService(serviceName string) ([]*MethodDescriptor, error)
}

Reflector performs reflection on the gRPC service to obtain the method type, services and methods

func NewReflector

func NewReflector(rc grpcreflectClient) Reflector

NewReflector creates a new Reflector from the reflection client

type ServerReflectionServer

type ServerReflectionServer struct {
	rpb.UnimplementedServerReflectionServer
	// contains filtered or unexported fields
}

func (*ServerReflectionServer) ServerReflectionInfo

ServerReflectionInfo is the reflection service handler.

type ServiceDescriptor

type ServiceDescriptor struct {
	*desc.ServiceDescriptor
}

ServiceDescriptor represents a service type

func ServiceDescriptorFromFileDescriptor

func ServiceDescriptorFromFileDescriptor(fd *desc.FileDescriptor, service string) *ServiceDescriptor

ServiceDescriptorFromFileDescriptor finds the service descriptor from a file descriptor This can be useful in tests that don't connect to a real server

func (*ServiceDescriptor) FindMethodByName

func (s *ServiceDescriptor) FindMethodByName(name string) (*MethodDescriptor, error)

FindMethodByName finds the method descriptor by name from the service descriptor

func (*ServiceDescriptor) GetMethods

func (s *ServiceDescriptor) GetMethods() ([]*MethodDescriptor, error)

GetMethods returns all of the RPC methods of this service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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