thrift

package
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BINARY thrift.TType = 18 // 兼容 thrift.BINARY 类型 即  []byte
)

Functions

func ReadByType

func ReadByType(ctx context.Context, protocol thrift.TProtocol, fieldType *FieldType, fieldTypeId thrift.TType) (res interface{}, err error)

func ReadList

func ReadList(ctx context.Context, protocol thrift.TProtocol, listType *FieldType) (interface{}, error)

func ReadMap

func ReadMap(ctx context.Context, protocol thrift.TProtocol, keyType *FieldType, valueType *FieldType) (res interface{}, err error)

func ReadSet

func ReadSet(ctx context.Context, protocol thrift.TProtocol, setType *FieldType) (interface{}, error)

func ReadStructField

func ReadStructField(ctx context.Context, outProtocol thrift.TProtocol, field *Field, fieldId int16, fieldTypeId thrift.TType) (interface{}, error)

func ReadStructFields

func ReadStructFields(ctx context.Context, inProtocol thrift.TProtocol, fields []*Field) (map[string]interface{}, error)

func WriteByType

func WriteByType(ctx context.Context, protocol thrift.TProtocol, fieldType *FieldType, value interface{}) (err error)

func WriteList

func WriteList(ctx context.Context, protocol thrift.TProtocol, listType *FieldType, value []interface{}) error

func WriteMap

func WriteMap(ctx context.Context, protocol thrift.TProtocol, keyType *FieldType, valueType *FieldType, value map[interface{}]interface{}) error

func WriteSet

func WriteSet(ctx context.Context, protocol thrift.TProtocol, setType *FieldType, value []interface{}) error

func WriteStructField

func WriteStructField(ctx context.Context, protocol thrift.TProtocol, field *Field, value interface{}) error

func WriteStructFields

func WriteStructFields(ctx context.Context, protocol thrift.TProtocol, name string, fields []*Field, value map[string]interface{}) error

Types

type Field

type Field struct {
	Num  int16      `json:"num"`
	Name string     `json:"name"`
	Type *FieldType `json:"type"`
}

type FieldType

type FieldType struct {
	TypeId        thrift.TType `json:"typeId"`
	StructInclude string       `json:"structInclude"`
	StructName    string       `json:"structName"`

	SetType      *FieldType `json:"setType"`
	ListType     *FieldType `json:"listType"`
	MapKeyType   *FieldType `json:"mapKeyType"`
	MapValueType *FieldType `json:"mapValueType"`
	// contains filtered or unexported fields
}

type MethodParam

type MethodParam struct {
	Name            string        `json:"name"`
	Args            []interface{} `json:"args"`
	ArgFields       []*Field      `json:"argFields,omitempty"`
	Result          interface{}   `json:"result"`
	Exceptions      []interface{} `json:"exceptions"`
	ResultType      *FieldType    `json:"resultFiled,omitempty"`
	ExceptionFields []*Field      `json:"exceptionFields,omitempty"`
	ReadStart       int64         `json:"readStart"`
	ReadEnd         int64         `json:"readEnd"`
	WriteStart      int64         `json:"writeStart"`
	WriteEnd        int64         `json:"writeEnd"`
	UseTime         int64         `json:"useTime"`
	Error           string        `json:"error"`
}

func (*MethodParam) Read

func (this_ *MethodParam) Read(ctx context.Context, inProtocol thrift.TProtocol) error

func (*MethodParam) String

func (this_ *MethodParam) String() string

func (*MethodParam) Write

func (this_ *MethodParam) Write(ctx context.Context, outProtocol thrift.TProtocol) error

type Service

type Service interface {
	Send(ctx context.Context, param *MethodParam) (result interface{}, err error)
}

type ServiceClient

type ServiceClient struct {
	TTransport thrift.TTransport
	TClient    thrift.TClient
	// contains filtered or unexported fields
}

func NewServiceClient

func NewServiceClient(c thrift.TClient) *ServiceClient

func NewServiceClientByAddress

func NewServiceClientByAddress(address string) (client *ServiceClient, err error)

func NewServiceClientProtocol

func NewServiceClientProtocol(t thrift.TTransport, inProtocol thrift.TProtocol, outProtocol thrift.TProtocol) *ServiceClient

func (*ServiceClient) Client_

func (this_ *ServiceClient) Client_() thrift.TClient

func (*ServiceClient) LastResponseMeta_

func (this_ *ServiceClient) LastResponseMeta_() thrift.ResponseMeta

func (*ServiceClient) Send

func (this_ *ServiceClient) Send(ctx context.Context, param *MethodParam) (result interface{}, err error)

func (*ServiceClient) SetLastResponseMeta_

func (this_ *ServiceClient) SetLastResponseMeta_(meta thrift.ResponseMeta)

func (*ServiceClient) Stop added in v0.3.6

func (this_ *ServiceClient) Stop()

type ServiceInfo

type ServiceInfo struct {
	*thrift.ServiceStatement
	Filename     string `json:"filename"`
	Name         string `json:"name"`
	RelativePath string `json:"relativePath"`
}

type Struct

type Struct struct {
	Name   string   `json:"name"`
	Fields []*Field `json:"fields"`
}

type Workspace

type Workspace struct {
	ServiceList []*ServiceInfo
	// contains filtered or unexported fields
}

func NewWorkspace

func NewWorkspace(dir string) *Workspace

func (*Workspace) AddIgnoreName

func (this_ *Workspace) AddIgnoreName(name string)

func (*Workspace) Clean

func (this_ *Workspace) Clean()

func (*Workspace) GetDir

func (this_ *Workspace) GetDir() string

func (*Workspace) GetEnum

func (this_ *Workspace) GetEnum(filename string, name string) *thrift.EnumStatement

func (*Workspace) GetErrors added in v0.2.9

func (this_ *Workspace) GetErrors() map[string]error

func (*Workspace) GetException

func (this_ *Workspace) GetException(filename string, name string) *thrift.ExceptionStatement

func (*Workspace) GetFieldByNode

func (this_ *Workspace) GetFieldByNode(filename string, fieldNode *thrift.FieldNode, structCache map[string]*Struct) (field *Field)

func (*Workspace) GetFieldDemoData added in v0.3.4

func (this_ *Workspace) GetFieldDemoData(filename string, fieldNode *Field) (res interface{})

func (*Workspace) GetFieldDemoDataByType added in v0.3.4

func (this_ *Workspace) GetFieldDemoDataByType(filename string, fieldNode *FieldType) (res interface{})

func (*Workspace) GetFieldTypeByNode

func (this_ *Workspace) GetFieldTypeByNode(filename string, fieldNode *thrift.FieldType, structCache map[string]*Struct) (fieldType *FieldType)

func (*Workspace) GetFields added in v0.3.2

func (this_ *Workspace) GetFields(filename string, params []*thrift.FieldNode, structCache map[string]*Struct) (fields []*Field)

func (*Workspace) GetFormatDir

func (this_ *Workspace) GetFormatDir() string

func (*Workspace) GetIncludePath

func (this_ *Workspace) GetIncludePath(filename string, name string) string

func (*Workspace) GetMethodParam

func (this_ *Workspace) GetMethodParam(filename string, serviceName string, methodName string, args ...interface{}) (param *MethodParam, err error)

func (*Workspace) GetRelativePath

func (this_ *Workspace) GetRelativePath(filename string) string

func (*Workspace) GetService

func (this_ *Workspace) GetService(filename string, name string) *thrift.ServiceStatement

func (*Workspace) GetServiceMethod

func (this_ *Workspace) GetServiceMethod(filename string, serviceName string, name string) *thrift.ServiceMethodNode

func (*Workspace) GetStruct

func (this_ *Workspace) GetStruct(filename string, name string) *thrift.StructStatement

func (*Workspace) GetStructByName

func (this_ *Workspace) GetStructByName(filename string, include string, name string, structCache map[string]*Struct) (res *Struct)

func (*Workspace) GetStructDemoData added in v0.3.4

func (this_ *Workspace) GetStructDemoData(filename string, include string, name string) (res interface{})

func (*Workspace) IncludeSubDir

func (this_ *Workspace) IncludeSubDir(includeSubDir bool)

func (*Workspace) InvokeByServerAddress

func (this_ *Workspace) InvokeByServerAddress(serverAddress string, filename string, serviceName string, methodName string, args ...interface{}) (param *MethodParam, err error)

func (*Workspace) IsIgnoreName

func (this_ *Workspace) IsIgnoreName(name string) bool

func (*Workspace) IsIncludeSubDir

func (this_ *Workspace) IsIncludeSubDir() bool

func (*Workspace) Load

func (this_ *Workspace) Load()

func (*Workspace) Reload

func (this_ *Workspace) Reload()

func (*Workspace) SetEnum

func (this_ *Workspace) SetEnum(filename string, value *thrift.EnumStatement)

func (*Workspace) SetException

func (this_ *Workspace) SetException(filename string, value *thrift.ExceptionStatement)

func (*Workspace) SetIncludePath

func (this_ *Workspace) SetIncludePath(dir string, filename string, value *thrift.IncludeStatement)

func (*Workspace) SetService

func (this_ *Workspace) SetService(filename string, value *thrift.ServiceStatement)

func (*Workspace) SetServiceMethod

func (this_ *Workspace) SetServiceMethod(filename string, serviceName string, value *thrift.ServiceMethodNode)

func (*Workspace) SetStruct

func (this_ *Workspace) SetStruct(filename string, value *thrift.StructStatement)

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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