parse

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package parse is parsed proto file to struct

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field added in v1.4.3

type Field struct {
	Name      string // field name
	FieldType string // field type
	Comment   string // field comment
}

Field message field

func (Field) GoTypeZero added in v1.4.3

func (r Field) GoTypeZero() string

GoTypeZero default zero value for type

type PbService

type PbService struct {
	Name      string           // Greeter
	LowerName string           // greeter first character to lower
	Methods   []*ServiceMethod // service methods

	CutServiceName      string // GreeterService --> Greeter
	LowerCutServiceName string // GreeterService --> greeter
}

PbService service fields

func GetServices

func GetServices(file *protogen.File) []*PbService

GetServices parse protobuf services

func (*PbService) RandNumber

func (s *PbService) RandNumber() int

RandNumber rand number 1~100

type RPCMethod added in v1.4.2

type RPCMethod struct {
	Name    string // SayHello
	Num     int    // one rpc RPCMethod can correspond to multiple http requests
	Request string // SayHelloReq
	Reply   string // SayHelloResp

	// http_rule
	Path         string // rule
	Method       string // HTTP Method
	Body         string
	ResponseBody string
}

RPCMethod describes a rpc method

func GetMethods added in v1.4.2

func GetMethods(m *protogen.Method) []*RPCMethod

GetMethods get rpc method descriptions

func (*RPCMethod) HandlerName added in v1.4.2

func (m *RPCMethod) HandlerName() string

HandlerName for gin handler name

func (*RPCMethod) HasPathParams added in v1.4.2

func (m *RPCMethod) HasPathParams() bool

HasPathParams whether to include routing parameters

func (*RPCMethod) InitPathParams added in v1.4.2

func (m *RPCMethod) InitPathParams()

InitPathParams conversion parameter routing {xx} --> :xx

type ServiceMethod

type ServiceMethod struct {
	MethodName    string // Create
	Request       string // CreateRequest
	RequestFields []*Field
	Reply         string // CreateReply
	ReplyFields   []*Field
	Comment       string // e.g. Create a record

	ServiceName         string // Greeter
	LowerServiceName    string // greeter first character to lower
	LowerCutServiceName string // GreeterService --> greeter

	// http_rule
	Path   string // rule
	Method string // HTTP Method
	Body   string
}

ServiceMethod RPCMethod fields

func (*ServiceMethod) AddOne

func (t *ServiceMethod) AddOne(i int) int

AddOne counter

Jump to

Keyboard shortcuts

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