Documentation ¶
Index ¶
- Variables
- type EnumNumber
- type FieldDescriptor
- func (f *FieldDescriptor) IsList() bool
- func (f *FieldDescriptor) IsMap() bool
- func (f *FieldDescriptor) JSONName() string
- func (f *FieldDescriptor) Kind() ProtoKind
- func (f *FieldDescriptor) MapKey() *TypeDescriptor
- func (f *FieldDescriptor) MapValue() *TypeDescriptor
- func (f *FieldDescriptor) Message() *MessageDescriptor
- func (f *FieldDescriptor) Name() string
- func (f *FieldDescriptor) Number() FieldNumber
- func (f *FieldDescriptor) Type() *TypeDescriptor
- type FieldNumber
- type MessageDescriptor
- type MethodDescriptor
- type Number
- type Options
- type ParseTarget
- type ProtoKind
- type ServiceDescriptor
- type Type
- type TypeDescriptor
- func (t *TypeDescriptor) BaseId() FieldNumber
- func (t *TypeDescriptor) Elem() *TypeDescriptor
- func (f *TypeDescriptor) IsList() bool
- func (f *TypeDescriptor) IsMap() bool
- func (t *TypeDescriptor) IsPacked() bool
- func (t *TypeDescriptor) Key() *TypeDescriptor
- func (t *TypeDescriptor) Message() *MessageDescriptor
- func (f *TypeDescriptor) Name() string
- func (t *TypeDescriptor) Type() Type
- func (f *TypeDescriptor) WireType() WireType
- type WireType
Constants ¶
This section is empty.
Variables ¶
var Kind2Wire = map[ProtoKind]WireType{ BoolKind: VarintType, EnumKind: VarintType, Int32Kind: VarintType, Sint32Kind: VarintType, Uint32Kind: VarintType, Int64Kind: VarintType, Sint64Kind: VarintType, Uint64Kind: VarintType, Sfixed32Kind: Fixed32Type, Fixed32Kind: Fixed32Type, FloatKind: Fixed32Type, Sfixed64Kind: Fixed64Type, Fixed64Kind: Fixed64Type, DoubleKind: Fixed64Type, StringKind: BytesType, BytesKind: BytesType, MessageKind: BytesType, GroupKind: StartGroupType, }
map from proto.ProtoKind to proto.WireType
Functions ¶
This section is empty.
Types ¶
type EnumNumber ¶
type EnumNumber int32
type FieldDescriptor ¶
type FieldDescriptor struct {
// contains filtered or unexported fields
}
func (*FieldDescriptor) IsList ¶
func (f *FieldDescriptor) IsList() bool
func (*FieldDescriptor) IsMap ¶
func (f *FieldDescriptor) IsMap() bool
func (*FieldDescriptor) JSONName ¶
func (f *FieldDescriptor) JSONName() string
func (*FieldDescriptor) Kind ¶
func (f *FieldDescriptor) Kind() ProtoKind
func (*FieldDescriptor) MapKey ¶
func (f *FieldDescriptor) MapKey() *TypeDescriptor
func (*FieldDescriptor) MapValue ¶
func (f *FieldDescriptor) MapValue() *TypeDescriptor
func (*FieldDescriptor) Message ¶
func (f *FieldDescriptor) Message() *MessageDescriptor
when List+Message it can get message element descriptor when Map it can get map key-value entry massage descriptor when Message it can get sub message descriptor
func (*FieldDescriptor) Name ¶
func (f *FieldDescriptor) Name() string
func (*FieldDescriptor) Number ¶
func (f *FieldDescriptor) Number() FieldNumber
func (*FieldDescriptor) Type ¶
func (f *FieldDescriptor) Type() *TypeDescriptor
type FieldNumber ¶
type FieldNumber int32
const ( MinValidNumber FieldNumber = 1 FirstReservedNumber FieldNumber = 19000 LastReservedNumber FieldNumber = 19999 MaxValidNumber FieldNumber = 1<<29 - 1 DefaultRecursionLimit = 10000 )
reserved field number min-max ranges in a proto message
type MessageDescriptor ¶
type MessageDescriptor struct {
// contains filtered or unexported fields
}
func (*MessageDescriptor) ByJSONName ¶
func (m *MessageDescriptor) ByJSONName(name string) *FieldDescriptor
func (*MessageDescriptor) ByName ¶
func (m *MessageDescriptor) ByName(name string) *FieldDescriptor
func (*MessageDescriptor) ByNumber ¶
func (m *MessageDescriptor) ByNumber(id FieldNumber) *FieldDescriptor
func (*MessageDescriptor) FieldsCount ¶
func (m *MessageDescriptor) FieldsCount() int
func (*MessageDescriptor) Name ¶
func (m *MessageDescriptor) Name() string
type MethodDescriptor ¶
type MethodDescriptor struct {
// contains filtered or unexported fields
}
func GetFnDescFromFile ¶
func GetFnDescFromFile(filePath, fnName string, opts Options, includeDirs ...string) *MethodDescriptor
GetFnDescFromFile get a fucntion descriptor from idl path (relative to your git root) and the function name
func (*MethodDescriptor) Input ¶
func (m *MethodDescriptor) Input() *TypeDescriptor
func (*MethodDescriptor) IsClientStreaming ¶ added in v0.2.8
func (m *MethodDescriptor) IsClientStreaming() bool
func (*MethodDescriptor) IsServerStreaming ¶ added in v0.2.8
func (m *MethodDescriptor) IsServerStreaming() bool
func (*MethodDescriptor) Name ¶
func (m *MethodDescriptor) Name() string
func (*MethodDescriptor) Output ¶
func (m *MethodDescriptor) Output() *TypeDescriptor
type Options ¶
type Options struct { // ParseServiceMode indicates how to parse service. ParseServiceMode meta.ParseServiceMode MapFieldWay meta.MapFieldWay // not implemented. ParseFieldRandomRate float64 // not implemented. ParseEnumAsInt64 bool // not implemented. SetOptionalBitmap bool // not implemented. UseDefaultValue bool // not implemented. ParseFunctionMode meta.ParseFunctionMode // not implemented. EnableProtoBase bool // not implemented. }
Options is options for parsing thrift IDL.
func NewDefaultOptions ¶
func NewDefaultOptions() Options
NewDefaultOptions creates a default Options.
func (Options) NewDesccriptorFromContent ¶
func (Options) NewDescriptorFromPath ¶
func (opts Options) NewDescriptorFromPath(ctx context.Context, path string, importDirs ...string) (*ServiceDescriptor, error)
NewDescritorFromContent creates a ServiceDescriptor from a proto path and its imports, which uses the given options. The importDirs is used to find the include files.
type ParseTarget ¶
type ParseTarget uint8
ParseTarget indicates the target to parse
const ( Request ParseTarget = iota Response Exception )
type ServiceDescriptor ¶
type ServiceDescriptor struct {
// contains filtered or unexported fields
}
func NewDescritorFromContent ¶
func NewDescritorFromContent(ctx context.Context, path, content string, includes map[string]string, importDirs ...string) (*ServiceDescriptor, error)
NewDescritorFromContent behaviors like NewDescritorFromPath, besides it uses DefaultOptions.
func NewDescritorFromPath ¶
func NewDescritorFromPath(ctx context.Context, path string, importDirs ...string) (*ServiceDescriptor, error)
NewDescritorFromPath behaviors like NewDescritorFromPath, besides it uses DefaultOptions.
func (*ServiceDescriptor) IsCombinedServices ¶ added in v0.4.3
func (s *ServiceDescriptor) IsCombinedServices() bool
func (*ServiceDescriptor) LookupMethodByName ¶
func (s *ServiceDescriptor) LookupMethodByName(name string) *MethodDescriptor
func (*ServiceDescriptor) Methods ¶
func (s *ServiceDescriptor) Methods() map[string]*MethodDescriptor
func (*ServiceDescriptor) Name ¶
func (s *ServiceDescriptor) Name() string
type Type ¶
type Type uint8
Node type (uint8) mapping ProtoKind the same value, except for UNKNOWN, LIST, MAP, ERROR
const ( UNKNOWN Type = 0 // unknown field type DOUBLE Type = 1 FLOAT Type = 2 INT64 Type = 3 UINT64 Type = 4 INT32 Type = 5 FIX64 Type = 6 FIX32 Type = 7 BOOL Type = 8 STRING Type = 9 GROUP Type = 10 // deprecated MESSAGE Type = 11 BYTE Type = 12 UINT32 Type = 13 ENUM Type = 14 SFIX32 Type = 15 SFIX64 Type = 16 SINT32 Type = 17 SINT64 Type = 18 LIST Type = 19 MAP Type = 20 ERROR Type = 255 )
func FromProtoKindToType ¶
FromProtoKindTType converts ProtoKind to Type
func (Type) TypeToKind ¶
type TypeDescriptor ¶
type TypeDescriptor struct {
// contains filtered or unexported fields
}
func FnRequest ¶
func FnRequest(fn *MethodDescriptor) *TypeDescriptor
FnRequest get the normal requestDescriptor
func FnResponse ¶
func FnResponse(fn *MethodDescriptor) *TypeDescriptor
FnResponse get hte normal responseDescriptor
func (*TypeDescriptor) BaseId ¶
func (t *TypeDescriptor) BaseId() FieldNumber
func (*TypeDescriptor) Elem ¶
func (t *TypeDescriptor) Elem() *TypeDescriptor
func (*TypeDescriptor) IsList ¶
func (f *TypeDescriptor) IsList() bool
func (*TypeDescriptor) IsMap ¶
func (f *TypeDescriptor) IsMap() bool
func (*TypeDescriptor) IsPacked ¶
func (t *TypeDescriptor) IsPacked() bool
func (*TypeDescriptor) Key ¶
func (t *TypeDescriptor) Key() *TypeDescriptor
func (*TypeDescriptor) Message ¶
func (t *TypeDescriptor) Message() *MessageDescriptor
func (*TypeDescriptor) Name ¶
func (f *TypeDescriptor) Name() string
func (*TypeDescriptor) Type ¶
func (t *TypeDescriptor) Type() Type
func (*TypeDescriptor) WireType ¶
func (f *TypeDescriptor) WireType() WireType