descriptor

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2017 License: BSD-3-Clause Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	// Method is the method which the endpoint is bound to.
	Method *Method
	// Index is a zero-origin index of the binding in the target method
	Index int
	// PathTmpl is path template where this method is mapped to.
	PathTmpl httprule.Template
	// HTTPMethod is the HTTP method which this method is mapped to.
	HTTPMethod string
	// PathParams is the list of parameters provided in HTTP request paths.
	PathParams []Parameter
	// Body describes parameters provided in HTTP request body.
	Body *Body
}

Binding describes how an HTTP endpoint is bound to a gRPC method.

func (*Binding) ExplicitParams

func (b *Binding) ExplicitParams() []string

ExplicitParams returns a list of explicitly bound parameters of "b", i.e. a union of field path for body and field paths for path parameters.

type Body

type Body struct {
	// FieldPath is a path to a proto field which the request body is mapped to.
	// The request body is mapped to the request type itself if FieldPath is empty.
	FieldPath FieldPath
}

Body describes a http requtest body to be sent to the method.

func (Body) RHS

func (b Body) RHS(msgExpr string) string

RHS returns a right-hand-side expression in go to be used to initialize method request object. It starts with "msgExpr", which is the go expression of the method request object.

type Enum

type Enum struct {
	// File is the file where the enum is defined
	File *File
	// Outers is a list of outer messages if this enum is a nested type.
	Outers []string
	*descriptor.EnumDescriptorProto

	Index int
}

Enum describes a protocol buffer enum types

func (*Enum) FQEN

func (e *Enum) FQEN() string

FQEN returns a fully qualified enum name of this enum.

type Field

type Field struct {
	// Message is the message type which this field belongs to.
	Message *Message
	// FieldMessage is the message type of the field.
	FieldMessage *Message
	*descriptor.FieldDescriptorProto
}

Field wraps descriptor.FieldDescriptorProto for richer features.

type FieldPath

type FieldPath []FieldPathComponent

FieldPath is a path to a field from a request message.

func (FieldPath) IsNestedProto3

func (p FieldPath) IsNestedProto3() bool

IsNestedProto3 indicates whether the FieldPath is a nested Proto3 path.

func (FieldPath) RHS

func (p FieldPath) RHS(msgExpr string) string

RHS is a right-hand-side expression in go to be used to assign a value to the target field. It starts with "msgExpr", which is the go expression of the method request object.

func (FieldPath) String

func (p FieldPath) String() string

String returns a string representation of the field path.

type FieldPathComponent

type FieldPathComponent struct {
	// Name is a name of the proto field which this component corresponds to.
	// TODO(yugui) is this necessary?
	Name string
	// Target is the proto field which this component corresponds to.
	Target *Field
}

FieldPathComponent is a path component in FieldPath

func (FieldPathComponent) LHS

func (c FieldPathComponent) LHS() string

LHS returns a left-hand-side expression in go for this field.

func (FieldPathComponent) RHS

func (c FieldPathComponent) RHS() string

RHS returns a right-hand-side expression in go for this field.

type File

type File struct {
	*descriptor.FileDescriptorProto
	// GoPkg is the go package of the go file generated from this file..
	GoPkg GoPackage
	// Messages is the list of messages defined in this file.
	Messages []*Message
	// Enums is the list of enums defined in this file.
	Enums []*Enum
	// Services is the list of services defined in this file.
	Services []*Service
}

File wraps descriptor.FileDescriptorProto for richer features.

type GoPackage

type GoPackage struct {
	// Path is the package path to the package.
	Path string
	// Name is the package name of the package
	Name string
	// Alias is an alias of the package unique within the current invokation of grpc-gateway generator.
	Alias string
}

GoPackage represents a golang package

func (GoPackage) Standard

func (p GoPackage) Standard() bool

Standard returns whether the import is a golang standard package.

func (GoPackage) String

func (p GoPackage) String() string

String returns a string representation of this package in the form of import line in golang.

type Message

type Message struct {
	// File is the file where the message is defined
	File *File
	// Outers is a list of outer messages if this message is a nested type.
	Outers []string
	*descriptor.DescriptorProto
	Fields []*Field

	// Index is proto path index of this message in File.
	Index int
}

Message describes a protocol buffer message types

func (*Message) FQMN

func (m *Message) FQMN() string

FQMN returns a fully qualified message name of this message.

func (*Message) GoType

func (m *Message) GoType(currentPackage string) string

GoType returns a go type name for the message type. It prefixes the type name with the package alias if its belonging package is not "currentPackage".

type Method

type Method struct {
	// Service is the service which this method belongs to.
	Service *Service
	*descriptor.MethodDescriptorProto

	// RequestType is the message type of requests to this method.
	RequestType *Message
	// ResponseType is the message type of responses from this method.
	ResponseType *Message
	Bindings     []*Binding
}

Method wraps descriptor.MethodDescriptorProto for richer features.

type Parameter

type Parameter struct {
	// FieldPath is a path to a proto field which this parameter is mapped to.
	FieldPath
	// Target is the proto field which this parameter is mapped to.
	Target *Field
	// Method is the method which this parameter is used for.
	Method *Method
}

Parameter is a parameter provided in http requests

func (Parameter) ConvertFuncExpr

func (p Parameter) ConvertFuncExpr() (string, error)

ConvertFuncExpr returns a go expression of a converter function. The converter function converts a string into a value for the parameter.

type Registry

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

Registry is a registry of information extracted from plugin.CodeGeneratorRequest.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns a new Registry.

func (*Registry) AddPkgMap

func (r *Registry) AddPkgMap(file, protoPkg string)

AddPkgMap adds a mapping from a .proto file to proto package name.

func (*Registry) GetAllFQENs

func (r *Registry) GetAllFQENs() []string

GetAllFQENs returns a list of all FQENs

func (*Registry) GetAllFQMNs

func (r *Registry) GetAllFQMNs() []string

GetAllFQMNs returns a list of all FQMNs

func (*Registry) Load

func (r *Registry) Load(req *plugin.CodeGeneratorRequest) error

Load loads definitions of services, methods, messages, enumerations and fields from "req".

func (*Registry) LookupEnum

func (r *Registry) LookupEnum(location, name string) (*Enum, error)

LookupEnum looks up a enum type by "name". It tries to resolve "name" from "location" if "name" is a relative enum name.

func (*Registry) LookupFile

func (r *Registry) LookupFile(name string) (*File, error)

LookupFile looks up a file by name.

func (*Registry) LookupMsg

func (r *Registry) LookupMsg(location, name string) (*Message, error)

LookupMsg looks up a message type by "name". It tries to resolve "name" from "location" if "name" is a relative message name.

func (*Registry) ReserveGoPackageAlias

func (r *Registry) ReserveGoPackageAlias(alias, pkgpath string) error

ReserveGoPackageAlias reserves the unique alias of go package. If succeeded, the alias will be never used for other packages in generated go files. If failed, the alias is already taken by another package, so you need to use another alias for the package in your go files.

func (*Registry) SetAllowDeleteBody added in v1.2.0

func (r *Registry) SetAllowDeleteBody(allow bool)

SetAllowDeleteBody controls whether http delete methods may have a body or fail loading if encountered.

func (*Registry) SetPrefix

func (r *Registry) SetPrefix(prefix string)

SetPrefix registers the prefix to be added to go package paths generated from proto package names.

type Service

type Service struct {
	// File is the file where this service is defined.
	File *File
	*descriptor.ServiceDescriptorProto
	// Methods is the list of methods defined in this service.
	Methods []*Method
}

Service wraps descriptor.ServiceDescriptorProto for richer features.

Jump to

Keyboard shortcuts

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