Documentation ¶
Index ¶
- Constants
- Variables
- func AysncNotifyDesc()
- func BlockingDial(ctx context.Context, address string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func ClientTransportCredentials(insecureSkipVerify bool, cacertFile, clientCertFile, clientKeyFile string) (credentials.TransportCredentials, error)
- func EnsureExtensions(source DescriptorSource, msg proto.Message) proto.Message
- func GetAllFiles(source DescriptorSource) ([]*desc.FileDescriptor, error)
- func GetDescriptorText(dsc desc.Descriptor, _ DescriptorSource) (string, error)
- func GetRemoteDescSource(target string) error
- func InitDescSource() error
- func ListMethods(source DescriptorSource, serviceName string) ([]string, error)
- func ListServices(source DescriptorSource) ([]string, error)
- func MakeTemplate(md *desc.MessageDescriptor) proto.Message
- func MetadataFromHeaders(headers []string) metadata.MD
- func MetadataToString(md metadata.MD) string
- func RequestParserAndFormatterFor(descSource DescriptorSource, emitJSONDefaultFields bool, in io.Reader) (RequestParser, Formatter, error)
- func ServerTransportCredentials(cacertFile, serverCertFile, serverKeyFile string, requireClientCerts bool) (credentials.TransportCredentials, error)
- func SetLogger(logger loggerType)
- func SetMode(mode int)
- func SetProtoFiles(importPath string, protoFile string)
- func SetProtoSetFiles(fileName string) (string, error)
- type DescSourceEntry
- func (d *DescSourceEntry) AysncNotifyDesc()
- func (d *DescSourceEntry) Close()
- func (d *DescSourceEntry) GetDescSource() (DescriptorSource, error)
- func (d *DescSourceEntry) InitDescSource() error
- func (d *DescSourceEntry) SetMode(mode int)
- func (d *DescSourceEntry) SetProtoFiles(importPath string, protoFile string)
- func (d *DescSourceEntry) SetProtoSetFiles(fileName string)
- type DescriptorSource
- func DescriptorSourceFromFileDescriptorSet(files *descpb.FileDescriptorSet) (DescriptorSource, error)
- func DescriptorSourceFromFileDescriptors(files ...*desc.FileDescriptor) (DescriptorSource, error)
- func DescriptorSourceFromProtoFiles(importPaths []string, fileNames ...string) (DescriptorSource, error)
- func DescriptorSourceFromProtoSets(fileNames ...string) (DescriptorSource, error)
- func DescriptorSourceFromServer(_ context.Context, refClient *grpcreflect.Client) DescriptorSource
- func GetDescSource() (DescriptorSource, error)
- type EngineHandler
- func (e *EngineHandler) Call(serviceName, methodName, data string) (*ResultModel, error)
- func (e *EngineHandler) CallWithAddr(serviceName, methodName, data string) (*ResultModel, error)
- func (e *EngineHandler) CallWithAddrCtx(ctx context.Context, serviceName, methodName, data string) (*ResultModel, error)
- func (e *EngineHandler) CallWithClient(client *grpc.ClientConn, serviceName, methodName, data string) (*ResultModel, error)
- func (e *EngineHandler) CallWithClientCtx(ctx context.Context, client *grpc.ClientConn, ...) (*ResultModel, error)
- func (e *EngineHandler) CallWithCtx(ctx context.Context, serviceName, methodName, data string) (*ResultModel, error)
- func (e *EngineHandler) CallWithCtxAndHeaders(ctx context.Context, serviceName, methodName, data string, ...) (*ResultModel, error)
- func (e *EngineHandler) Close() error
- func (e *EngineHandler) DoConnect(target string) (*grpc.ClientConn, error)
- func (e *EngineHandler) ExtractProtoType(svc, mth string) (proto.Message, proto.Message, error)
- func (e *EngineHandler) Init(target string) error
- func (e *EngineHandler) InitFormater() error
- func (e *EngineHandler) ListMethods(svc string) ([]string, error)
- func (e *EngineHandler) ListServiceAndMethods() (map[string][]ServMethodModel, error)
- func (e *EngineHandler) ListServices() ([]string, error)
- func (e *EngineHandler) SetMode(mode int)
- func (e *EngineHandler) SetProtoSetFiles(fileName string) (string, error)
- type EventHandler
- type Format
- type Formatter
- type InEventHooker
- type InvocationEventHandler
- type InvokeHandler
- type Option
- func SetCtx(val context.Context, cancel context.CancelFunc) Option
- func SetDescSourceCtl(val *DescSourceEntry) Option
- func SetDialTime(val time.Duration) Option
- func SetHookHandler(handler InvocationEventHandler) Option
- func SetKeepAliveTime(val time.Duration) Option
- func SetRecvMsgSize(val int) Option
- type ReqRespTypes
- type RequestParser
- type RequestSupplier
- type ResultModel
- type ServMethodModel
Constants ¶
const ( // ProtoSetMode TODO ProtoSetMode = iota // 0 // ProtoFilesMode TODO ProtoFilesMode // 1 // ProtoReflectMode TODO ProtoReflectMode // 2 )
const ( // FormatJSON TODO FormatJSON = Format("json") )
Variables ¶
var ErrReflectionNotSupported = errors.New("server does not support the reflection API")
ErrReflectionNotSupported is returned by DescriptorSource operations that rely on interacting with the reflection service when the source does not actually expose the reflection service. When this occurs, an alternate source (like file descriptor sets) must be used.
Functions ¶
func BlockingDial ¶
func BlockingDial(ctx context.Context, address string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
BlockingDial is a helper method to dial the given address, using optional TLS credentials, and blocking until the returned connection is ready. If the given credentials are nil, the connection will be insecure (plain-text).
func ClientTransportCredentials ¶
func ClientTransportCredentials(insecureSkipVerify bool, cacertFile, clientCertFile, clientKeyFile string) (credentials.TransportCredentials, error)
ClientTransportCredentials builds transport credentials for a gRPC client using the given properties. If cacertFile is blank, only standard trusted certs are used to verify the server certs. If clientCertFile is blank, the client will not use a client certificate. If clientCertFile is not blank then clientKeyFile must not be blank.
func EnsureExtensions ¶
func EnsureExtensions(source DescriptorSource, msg proto.Message) proto.Message
EnsureExtensions uses the given descriptor source to download extensions for the given message. It returns a copy of the given message, but as a dynamic message that knows about all extensions known to the given descriptor source.
func GetAllFiles ¶
func GetAllFiles(source DescriptorSource) ([]*desc.FileDescriptor, error)
GetAllFiles uses the given descriptor source to return a list of file descriptors.
func GetDescriptorText ¶
func GetDescriptorText(dsc desc.Descriptor, _ DescriptorSource) (string, error)
GetDescriptorText returns a string representation of the given descriptor. This returns a snippet of proto source that describes the given element.
func ListMethods ¶
func ListMethods(source DescriptorSource, serviceName string) ([]string, error)
ListMethods uses the given descriptor source to return a sorted list of method names for the specified fully-qualified service name.
func ListServices ¶
func ListServices(source DescriptorSource) ([]string, error)
ListServices uses the given descriptor source to return a sorted list of fully-qualified service names.
func MakeTemplate ¶
func MakeTemplate(md *desc.MessageDescriptor) proto.Message
MakeTemplate returns a message instance for the given descriptor that is a suitable template for creating an instance of that message in JSON. In particular, it ensures that any repeated fields (which include map fields) are not empty, so they will render with a single element (to show the types and optionally nested fields). It also ensures that nested messages are not nil by setting them to a message that is also fleshed out as a template message.
func MetadataFromHeaders ¶
MetadataFromHeaders converts a list of header strings (each string in "Header-Name: Header-Value" form) into metadata. If a string has a header name without a value (e.g. does not contain a colon), the value is assumed to be blank. Binary headers (those whose names end in "-bin") should be base64-encoded. But if they cannot be base64-decoded, they will be assumed to be in raw form and used as is.
func MetadataToString ¶
MetadataToString returns a string representation of the given metadata, for displaying to users.
func RequestParserAndFormatterFor ¶
func RequestParserAndFormatterFor(descSource DescriptorSource, emitJSONDefaultFields bool, in io.Reader) (RequestParser, Formatter, error)
RequestParserAndFormatterFor returns a request parser and formatter for the given format.
func ServerTransportCredentials ¶
func ServerTransportCredentials(cacertFile, serverCertFile, serverKeyFile string, requireClientCerts bool) (credentials.TransportCredentials, error)
ServerTransportCredentials builds transport credentials for a gRPC server using the given properties. If cacertFile is blank, the server will not request client certs unless requireClientCerts is true. When requireClientCerts is false and cacertFile is not blank, the server will verify client certs when presented, but will not require client certs. The serverCertFile and serverKeyFile must both not be blank.
func SetProtoSetFiles ¶
SetProtoSetFiles TODO
Types ¶
type DescSourceEntry ¶
type DescSourceEntry struct {
// contains filtered or unexported fields
}
DescSourceEntry TODO
func (*DescSourceEntry) AysncNotifyDesc ¶
func (d *DescSourceEntry) AysncNotifyDesc()
AysncNotifyDesc TODO
func (*DescSourceEntry) GetDescSource ¶
func (d *DescSourceEntry) GetDescSource() (DescriptorSource, error)
GetDescSource TODO
func (*DescSourceEntry) InitDescSource ¶
func (d *DescSourceEntry) InitDescSource() error
InitDescSource TODO
func (*DescSourceEntry) SetProtoFiles ¶
func (d *DescSourceEntry) SetProtoFiles(importPath string, protoFile string)
SetProtoFiles TODO
func (*DescSourceEntry) SetProtoSetFiles ¶
func (d *DescSourceEntry) SetProtoSetFiles(fileName string)
SetProtoSetFiles TODO
type DescriptorSource ¶
type DescriptorSource interface { // ListServices returns a list of fully-qualified service names. It will be all services in a set of // descriptor files or the set of all services exposed by a gRPC server. ListServices() ([]string, error) // FindSymbol returns a descriptor for the given fully-qualified symbol name. FindSymbol(fullyQualifiedName string) (desc.Descriptor, error) // AllExtensionsForType returns all known extension fields that extend the given message type name. AllExtensionsForType(typeName string) ([]*desc.FieldDescriptor, error) }
DescriptorSource is a source of protobuf descriptor information. It can be backed by a FileDescriptorSet proto (like a file generated by protoc) or a remote server that supports the reflection API.
func DescriptorSourceFromFileDescriptorSet ¶
func DescriptorSourceFromFileDescriptorSet(files *descpb.FileDescriptorSet) (DescriptorSource, error)
DescriptorSourceFromFileDescriptorSet creates a DescriptorSource that is backed by the FileDescriptorSet.
func DescriptorSourceFromFileDescriptors ¶
func DescriptorSourceFromFileDescriptors(files ...*desc.FileDescriptor) (DescriptorSource, error)
DescriptorSourceFromFileDescriptors creates a DescriptorSource that is backed by the given file descriptors
func DescriptorSourceFromProtoFiles ¶
func DescriptorSourceFromProtoFiles(importPaths []string, fileNames ...string) (DescriptorSource, error)
DescriptorSourceFromProtoFiles creates a DescriptorSource that is backed by the named files, whose contents are Protocol Buffer source files. The given importPaths are used to locate any imported files.
func DescriptorSourceFromProtoSets ¶
func DescriptorSourceFromProtoSets(fileNames ...string) (DescriptorSource, error)
DescriptorSourceFromProtoSets creates a DescriptorSource that is backed by the named files, whose contents are encoded FileDescriptorSet protos.
func DescriptorSourceFromServer ¶
func DescriptorSourceFromServer(_ context.Context, refClient *grpcreflect.Client) DescriptorSource
DescriptorSourceFromServer creates a DescriptorSource that uses the given gRPC reflection client to interrogate a server for descriptor information. If the server does not support the reflection API then the various DescriptorSource methods will return ErrReflectionNotSupported
type EngineHandler ¶
type EngineHandler struct {
// contains filtered or unexported fields
}
EngineHandler TODO
func (*EngineHandler) Call ¶
func (e *EngineHandler) Call(serviceName, methodName, data string) (*ResultModel, error)
Call TODO
func (*EngineHandler) CallWithAddr ¶
func (e *EngineHandler) CallWithAddr(serviceName, methodName, data string) (*ResultModel, error)
CallWithAddr TODO
func (*EngineHandler) CallWithAddrCtx ¶
func (e *EngineHandler) CallWithAddrCtx(ctx context.Context, serviceName, methodName, data string) (*ResultModel, error)
CallWithAddrCtx TODO
func (*EngineHandler) CallWithClient ¶
func (e *EngineHandler) CallWithClient(client *grpc.ClientConn, serviceName, methodName, data string) (*ResultModel, error)
CallWithClient TODO
func (*EngineHandler) CallWithClientCtx ¶
func (e *EngineHandler) CallWithClientCtx(ctx context.Context, client *grpc.ClientConn, serviceName, methodName, data string) (*ResultModel, error)
CallWithClientCtx TODO
func (*EngineHandler) CallWithCtx ¶
func (e *EngineHandler) CallWithCtx(ctx context.Context, serviceName, methodName, data string) (*ResultModel, error)
CallWithCtx TODO
func (*EngineHandler) CallWithCtxAndHeaders ¶
func (e *EngineHandler) CallWithCtxAndHeaders(ctx context.Context, serviceName, methodName, data string, rpcHeaders multiString) (*ResultModel, error)
CallWithCtxAndHeaders TODO
func (*EngineHandler) DoConnect ¶
func (e *EngineHandler) DoConnect(target string) (*grpc.ClientConn, error)
DoConnect TODO
func (*EngineHandler) ExtractProtoType ¶
ExtractProtoType TODO
func (*EngineHandler) ListMethods ¶
func (e *EngineHandler) ListMethods(svc string) ([]string, error)
ListMethods TODO
func (*EngineHandler) ListServiceAndMethods ¶
func (e *EngineHandler) ListServiceAndMethods() (map[string][]ServMethodModel, error)
ListServiceAndMethods TODO
func (*EngineHandler) ListServices ¶
func (e *EngineHandler) ListServices() ([]string, error)
ListServices TODO
func (*EngineHandler) SetProtoSetFiles ¶
func (e *EngineHandler) SetProtoSetFiles(fileName string) (string, error)
SetProtoSetFiles TODO
type EventHandler ¶
type EventHandler struct {
// contains filtered or unexported fields
}
EventHandler TODO
var DefaultEventHandler *EventHandler
DefaultEventHandler TODO
func SetDefaultEventHandler ¶
func SetDefaultEventHandler(descSource DescriptorSource, formatter Formatter) *EventHandler
SetDefaultEventHandler TODO
func (*EventHandler) FormatResponse ¶
func (h *EventHandler) FormatResponse(resp proto.Message) string
FormatResponse TODO
type Formatter ¶
Formatter translates messages into string representations.
func NewJSONFormatter ¶
func NewJSONFormatter(emitDefaults bool, resolver jsonpb.AnyResolver) Formatter
NewJSONFormatter returns a formatter that returns JSON strings.
func ParseFormatterByDesc ¶
func ParseFormatterByDesc(descSource DescriptorSource, emitFields bool) (Formatter, error)
ParseFormatterByDesc TODO
type InEventHooker ¶
type InEventHooker struct { }
InEventHooker TODO
func (*InEventHooker) OnReceiveData ¶
func (h *InEventHooker) OnReceiveData(md metadata.MD, resp string, respErr error)
OnReceiveData TODO
func (*InEventHooker) OnReceiveTrailers ¶
func (h *InEventHooker) OnReceiveTrailers(stat *status.Status, md metadata.MD)
OnReceiveTrailers TODO
type InvocationEventHandler ¶
type InvocationEventHandler interface { // OnReceiveHeaders is called when response headers and message have been received. OnReceiveData(metadata.MD, string, error) // OnReceiveTrailers is called when response trailers and final RPC status have been received. OnReceiveTrailers(*status.Status, metadata.MD) }
InvocationEventHandler is a bag of callbacks for handling events that occur in the course of invoking an RPC.
type InvokeHandler ¶
type InvokeHandler struct {
// contains filtered or unexported fields
}
InvokeHandler TODO
func (*InvokeHandler) InvokeRPC ¶
func (in *InvokeHandler) InvokeRPC(ctx context.Context, source DescriptorSource, ch grpcdynamic.Channel, svc, mth string, headers []string, requestData RequestSupplier) (*ResultModel, error)
InvokeRPC uses the given gRPC channel to invoke the given method.
type Option ¶
type Option func(*EngineHandler) error
Option TODO
func SetHookHandler ¶
func SetHookHandler(handler InvocationEventHandler) Option
SetHookHandler TODO
type ReqRespTypes ¶
type ReqRespTypes struct {
// contains filtered or unexported fields
}
ReqRespTypes TODO
type RequestParser ¶
type RequestParser interface { // Next parses input data into the given request message. If called after // input is exhausted, it returns io.EOF. If the caller re-uses the same // instance in multiple calls to Next, it should call msg.Reset() in between // each call. Next(msg proto.Message) error }
RequestParser processes input into messages.
func NewJSONRequestParser ¶
func NewJSONRequestParser(in io.Reader, resolver jsonpb.AnyResolver) RequestParser
NewJSONRequestParser returns a RequestParser that reads data in JSON format from the given reader.
func RequestParserFor ¶
func RequestParserFor(descSource DescriptorSource, in io.Reader) (RequestParser, error)
RequestParserFor TODO
type RequestSupplier ¶
RequestSupplier is a function that is called to populate messages for a gRPC operation.