parser

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 27 Imported by: 1

Documentation

Overview

Package parser provides the ability of the parser to generate IDC descriptions from specified files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSECVEnabled

func CheckSECVEnabled(nfd *descriptor.FileDescriptor) bool

CheckSECVEnabled checks if validation rules are defined in the pb.

func GetPackage

func GetPackage(fd *descriptor.FileDescriptor, language string) (string, error)

GetPackage combines the package directive and option $lang_package to get a valid package name. The package directive is like package trpc.testapp.testserver;. The option $lang_package is like option go_package="trpc.group/trpcprotocol/testapp/testserver";.

func GetPbPackage

func GetPbPackage(fd *descriptor.FileDescriptor, fileOption string) (string, error)

GetPbPackage retrieves the path where the protobuf files are located. When a file option (such as go_package) has a corresponding value in fd.FileOptions, the returned pbPackage will be in the form of "trpc.group/trpcprotocol/testapp/testserver". Otherwise, pbPackage will be in the form of "trpc.testapp.testserver".

func LoadDescriptorSet

func LoadDescriptorSet(descriptorSetInFile, protofile string, opts ...Option) (*descriptor.FileDescriptor, error)

LoadDescriptorSet loads the file descriptor from the given file name.

func Parse

func Parse(protofile string, dirs []string, typ config.IDLType, opts ...Option) (*descriptor.FileDescriptor, error)

Parse parses the given file, which can be either a Protocol Buffer or FlatBuffers file.

func ParseFlatbuffers

func ParseFlatbuffers(protofile string, protodirs []string, opts ...Option) (*descriptor.FileDescriptor, error)

ParseFlatbuffers parses a flatbuffers file and returns a FileDescriptor object that can be used for template filling.

func ParseProtoFile

func ParseProtoFile(protofile string, protodirs []string, opts ...Option) (*descriptor.FileDescriptor, error)

ParseProtoFile parses a proto file and returns a constructed FileDescriptor object that can be used for template filling.

ParseProtoFile is responsible for: - parsing the pb file to get the original description information - checking project constraints, such as whether custom constraints such as go_option and method option are specified.

Types

type HttpRule

type HttpRule[HR any] interface {
	*annotations.HttpRule
	GetAdditionalBindings() []HR
	GetBody() string
	GetResponseBody() string
}

HttpRule provide interface for http rule.

type Option

type Option func(*options)

Option parse option

func WithAPPName

func WithAPPName(name string) Option

WithAPPName specifies app name to use in stub code.

func WithAliasAsClientRPCName

func WithAliasAsClientRPCName(enabled bool) Option

WithAliasAsClientRPCName sets alias as client rpc name.

func WithAliasOn

func WithAliasOn(enabled bool) Option

WithAliasOn enable alias

func WithLanguage

func WithLanguage(lang string) Option

WithLanguage specify language for further checking

func WithMultiVersion

func WithMultiVersion(enabled bool) Option

WithMultiVersion enable multi-version support.

func WithRPCOnly

func WithRPCOnly(enabled bool) Option

WithRPCOnly enable RPC only

func WithServerName

func WithServerName(name string) Option

WithServerName specifies server name to use in stub code.

type SwaggerParam

type SwaggerParam interface {
	*swagger.SwaggerParam
	GetName() string
	GetRequired() bool
	GetDefault() string
}

type SwaggerRule

type SwaggerRule[SP SwaggerParam] interface {
	*swagger.SwaggerRule
	GetTitle() string
	GetDescription() string
	GetMethod() string
	GetParams() []SP
}

Jump to

Keyboard shortcuts

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