desc

package module
v0.0.0-...-2eb4f34 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: MIT Imports: 21 Imported by: 1

README

desc

search descriptors from go source code for tgrpc

google.protobuf/descriptor
protoc --gogo_out=plugins=grpc:. google.protobuf/descriptor.proto
go get github.com/tgrpc/desc/desc

desc -m helloworld.Greeter/SayHello '$GOPATH/src/github.com/tgrpc'

raw descs will be saved in file helloworld.Greeter.desc . helloworld.Greeter.desc can be used in tgrpc.toml like this:

log_level = "debug"
[service]
[service.Greeter]
address = "localhost:2080"
reuse_desc = true
proto_base_path = "$GOPATH/src/github.com/tgrpc/ngrpc"
include_imports = "helloworld/helloworld.proto"
keepalive = "100s"
raw_descs = ['H4sIAAAAAAAC/2ySz47aMBDGa5wQGKQKTRGyOERRDlVOVIWqvbeHXji5Uu+BGLAUYogNq32Tve3r7HEfYcW+yMp2+LNib/59M6P55ksAyrxajbe1MgphLcpS3am6LNJfEM2kNlzscAhttVxqYRhJSBbyhnAAYSk30rCWkz2kKwhmebVChKDKN8LNdLl74wg6c1mbdZHfuyHKz4zfoHMQtZaq0owmNOtNvowvfsb/fY2fm9JHAlGj4mdoyaKx15IFMoiaPreny09obRVCLxj1tuzbHnKQ04lmQULtIQ6cqk2tWZjQrMs9+N6fPzRrJzSj3INTl1aNEpoR7iHl0PEZ6i1+hdAmrRlxt/Wvb7N5cV/GGMAok5d/1L46JXulpAnAX2HchNh9FPJkDz1b/ifqg1wI/A6BNYHv0mw+7WhwK+otTiFqduDwuuGyeHTj/3f/6RiT52NMXo4xeXiNP83b7q+avgUAAP//cpNxkGMCAAA=']

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPBGo

func AddPBGo(pg *PBGo)

func Base64Decode

func Base64Decode(str string) ([]byte, error)

func Base64Encode

func Base64Encode(bs []byte) string

func Collect

func Collect(dirs ...string)

func Cond

func Cond(dir string, info os.FileInfo) (ifExec bool, skip error)

func DecodeFileDescriptorSet

func DecodeFileDescriptorSet(method string, fileDescriptorSet *descriptor.FileDescriptorSet) (*descriptor.FileDescriptorSet, error)

func DecodeFileDescriptorSetByBase64Str

func DecodeFileDescriptorSetByBase64Str(descSetOut string, raws []string) (*descriptor.FileDescriptorSet, error)

func DecodeFileDescriptorSetByRaw

func DecodeFileDescriptorSetByRaw(descSetOut string, raws []string) (*descriptor.FileDescriptorSet, error)

func DecodeGoGoFileDescriptorSetByBase64Str

func DecodeGoGoFileDescriptorSetByBase64Str(descSetOut string, raws []string) (*gogodescriptor.FileDescriptorSet, error)

func ExtractFile

func ExtractFile(gz []byte) (*descriptor.FileDescriptorProto, error)

extractFile extracts a FileDescriptorProto from a gzip'd buffer.

func ExtractGoGoFile

func ExtractGoGoFile(gz []byte) (*gogodescriptor.FileDescriptorProto, error)

extractFile extracts a FileDescriptorProto from a gzip'd buffer.

func GenDescriptorSet

func GenDescriptorSet(protoPath, descSetOut, incImp string) error

protoPath 与 incImp 不能有重叠部分 incImp例子:服务目录/服务proto文件

func GetDescriptor

func GetDescriptor(protoBasePath, method, incImp string, reuseDesc bool, rawDescs []string) (*descriptor.FileDescriptorSet, error)

method: pkg.Service incImp:pkg.service.proto

func GetDescriptorSource

func GetDescriptorSource(protoBasePath, method, incImp string, reuseDesc bool, rawDescs []string) (grpcurl.DescriptorSource, error)

func GetMethod

func GetMethod(method string) (string, error)

exp: helloworld.Greeter/SayHello

func GetPackageName

func GetPackageName(method string) (string, error)

helloworld.Greeter

func GetServiceName

func GetServiceName(method string) (string, error)

helloworld.Greeter

func Parse2Byte

func Parse2Byte(v string) byte

func Parse2Bytes

func Parse2Bytes(strs []string) []byte

func ParseStr2Bytes

func ParseStr2Bytes(str string) []byte

func SearchDescSrcByRawDescs

func SearchDescSrcByRawDescs(method string, rawDescs []string, pbDirs ...string) (grpcurl.DescriptorSource, error)

func SetLog

func SetLog(logLevel string)

func SortFileDescriptorSet

func SortFileDescriptorSet(fileDescriptorSet *descriptor.FileDescriptorSet, fileDescriptorProto *descriptor.FileDescriptorProto) (*descriptor.FileDescriptorSet, error)

func Try

func Try(method string, pbDirs ...string) (grpcurl.DescriptorSource, error)

Types

type AssociPB

type AssociPB struct {
	PBs []*PBGo
}

相似pb

func SearchByFilename

func SearchByFilename(filename string) *AssociPB

func SearchByImportFilename

func SearchByImportFilename(importfilename string) *AssociPB

func SearchByMethod

func SearchByMethod(packageName, serviceName, method string, unique map[string]bool) *AssociPB

type PBGo

type PBGo struct {
	AbsDir      string
	ParientName string
	Name        string
}

func NewPBGo

func NewPBGo(dir, name string) *PBGo

func (*PBGo) ImportName

func (pg *PBGo) ImportName() string

type ProtoDesc

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

func NewProtoDesc

func NewProtoDesc(fileDescriptorSet *descriptor.FileDescriptorSet, rawDescs []string, pbDirs ...string) *ProtoDesc

type ServiceDescriptor

type ServiceDescriptor struct {
	*descriptor.ServiceDescriptorProto

	FullyQualifiedPath  string
	FileDescriptorProto *descriptor.FileDescriptorProto
	FileDescriptorSet   *descriptor.FileDescriptorSet
}

Descriptor is an extracted service.

func GetServiceDescriptor

func GetServiceDescriptor(fileDescriptorSets []*descriptor.FileDescriptorSet, path string) (*ServiceDescriptor, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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