proto

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

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 (*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 Number

type Number = protowire.Number

define Number = protowire.Number (int32)

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 (opts Options) NewDesccriptorFromContent(ctx context.Context, path, content string, includes map[string]string, importDirs ...string) (*ServiceDescriptor, error)

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 ProtoKind

type ProtoKind = protoreflect.Kind

define ProtoKind = protoreflect.Kind (int8)

const (
	DoubleKind ProtoKind = iota + 1
	FloatKind
	Int64Kind
	Uint64Kind
	Int32Kind
	Fixed64Kind
	Fixed32Kind
	BoolKind
	StringKind
	GroupKind
	MessageKind
	BytesKind
	Uint32Kind
	EnumKind
	Sfixed32Kind
	Sfixed64Kind
	Sint32Kind
	Sint64Kind
)

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

func FromProtoKindToType(kind ProtoKind, isList bool, isMap bool) Type

FromProtoKindTType converts ProtoKind to Type

func (Type) IsComplex

func (p Type) IsComplex() bool

IsComplex tells if the type is one of STRUCT, MAP, SET, LIST

func (Type) IsInt

func (p Type) IsInt() bool

IsInt containing isUint

func (Type) IsPacked

func (p Type) IsPacked() bool

func (Type) IsUint

func (p Type) IsUint() bool

func (Type) NeedVarint

func (p Type) NeedVarint() bool

check if the type need Varint encoding

func (Type) String

func (p Type) String() string

String for format and print

func (Type) TypeToKind

func (p Type) TypeToKind() ProtoKind

func (Type) Valid

func (p Type) Valid() bool

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

type WireType

type WireType int8

protobuf encoding wire type

const (
	VarintType     WireType = 0
	Fixed32Type    WireType = 5
	Fixed64Type    WireType = 1
	BytesType      WireType = 2
	StartGroupType WireType = 3 // deprecated
	EndGroupType   WireType = 4 // deprecated
)

func (WireType) String

func (p WireType) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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