reflection

package
v0.0.0-...-3e265f4 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2019 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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

Jump to

Keyboard shortcuts

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