thrift

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 31 Imported by: 2

Documentation

Overview

Package thrift provides thrift idl parser and codec for generic call

Index

Constants

This section is empty.

Variables

View Source
var BaseResp_Extra_DEFAULT map[string]string
View Source
var Base_Extra_DEFAULT map[string]string

Functions

func Parse

Parse descriptor from parser.Thrift

func SetDefaultParseMode added in v0.1.0

func SetDefaultParseMode(m ParseMode)

SetDefaultParseMode sets the default parse mode.

Types

type Base

type Base struct {
	LogID string `thrift:"LogID,1" json:"LogID"`

	Caller string `thrift:"Caller,2" json:"Caller"`

	Addr string `thrift:"Addr,3" json:"Addr"`

	Client string `thrift:"Client,4" json:"Client"`

	TrafficEnv *TrafficEnv `thrift:"TrafficEnv,5" json:"TrafficEnv,omitempty"`

	Extra map[string]string `thrift:"Extra,6" json:"Extra,omitempty"`
}

func NewBase

func NewBase() *Base

func (*Base) GetAddr

func (p *Base) GetAddr() string

func (*Base) GetCaller

func (p *Base) GetCaller() string

func (*Base) GetClient

func (p *Base) GetClient() string

func (*Base) GetExtra

func (p *Base) GetExtra() map[string]string

func (*Base) GetLogID

func (p *Base) GetLogID() string

func (*Base) GetTrafficEnv

func (p *Base) GetTrafficEnv() *TrafficEnv

func (*Base) IsSetExtra

func (p *Base) IsSetExtra() bool

func (*Base) IsSetTrafficEnv

func (p *Base) IsSetTrafficEnv() bool

func (*Base) Read

func (p *Base) Read(iprot thrift.TProtocol) (err error)

func (*Base) ReadField1

func (p *Base) ReadField1(iprot thrift.TProtocol) error

func (*Base) ReadField2

func (p *Base) ReadField2(iprot thrift.TProtocol) error

func (*Base) ReadField3

func (p *Base) ReadField3(iprot thrift.TProtocol) error

func (*Base) ReadField4

func (p *Base) ReadField4(iprot thrift.TProtocol) error

func (*Base) ReadField5

func (p *Base) ReadField5(iprot thrift.TProtocol) error

func (*Base) ReadField6

func (p *Base) ReadField6(iprot thrift.TProtocol) error

func (*Base) SetAddr

func (p *Base) SetAddr(val string)

func (*Base) SetCaller

func (p *Base) SetCaller(val string)

func (*Base) SetClient

func (p *Base) SetClient(val string)

func (*Base) SetExtra

func (p *Base) SetExtra(val map[string]string)

func (*Base) SetLogID

func (p *Base) SetLogID(val string)

func (*Base) SetTrafficEnv

func (p *Base) SetTrafficEnv(val *TrafficEnv)

func (*Base) String

func (p *Base) String() string

func (*Base) Write

func (p *Base) Write(oprot thrift.TProtocol) (err error)

type BaseResp

type BaseResp struct {
	StatusMessage string `thrift:"StatusMessage,1" json:"StatusMessage"`

	StatusCode int32 `thrift:"StatusCode,2" json:"StatusCode"`

	Extra map[string]string `thrift:"Extra,3" json:"Extra,omitempty"`
}

func NewBaseResp

func NewBaseResp() *BaseResp

func (*BaseResp) GetExtra

func (p *BaseResp) GetExtra() map[string]string

func (*BaseResp) GetStatusCode

func (p *BaseResp) GetStatusCode() int32

func (*BaseResp) GetStatusMessage

func (p *BaseResp) GetStatusMessage() string

func (*BaseResp) IsSetExtra

func (p *BaseResp) IsSetExtra() bool

func (*BaseResp) Read

func (p *BaseResp) Read(iprot thrift.TProtocol) (err error)

func (*BaseResp) ReadField1

func (p *BaseResp) ReadField1(iprot thrift.TProtocol) error

func (*BaseResp) ReadField2

func (p *BaseResp) ReadField2(iprot thrift.TProtocol) error

func (*BaseResp) ReadField3

func (p *BaseResp) ReadField3(iprot thrift.TProtocol) error

func (*BaseResp) SetExtra

func (p *BaseResp) SetExtra(val map[string]string)

func (*BaseResp) SetStatusCode

func (p *BaseResp) SetStatusCode(val int32)

func (*BaseResp) SetStatusMessage

func (p *BaseResp) SetStatusMessage(val string)

func (*BaseResp) String

func (p *BaseResp) String() string

func (*BaseResp) Write

func (p *BaseResp) Write(oprot thrift.TProtocol) (err error)

type MessageReader

type MessageReader interface {
	Read(ctx context.Context, method string, in thrift.TProtocol) (interface{}, error)
}

MessageReader read from thrift.TProtocol with method

type MessageWriter

type MessageWriter interface {
	Write(ctx context.Context, out thrift.TProtocol, msg interface{}, requestBase *Base) error
}

MessageWriter write to thrift.TProtocol

type MsgType added in v0.7.0

type MsgType int
const (
	Void MsgType = iota
	String
)

type ParseMode added in v0.1.0

type ParseMode int

ParseMode .

const (
	// LastServiceOnly forces the parser to parse only the last service definition.
	LastServiceOnly ParseMode = iota

	// FirstServiceOnly forces the parser to parse only the first service definition.
	FirstServiceOnly

	// CombineServices forces the parser to combine methods of all service definitions.
	// Note that method names of the service definitions can not be duplicate.
	CombineServices
)

func DefaultParseMode added in v0.1.0

func DefaultParseMode() ParseMode

DefaultParseMode returns the default parse mode.

type ReadHTTPPbResponse added in v0.4.0

type ReadHTTPPbResponse struct {
	// contains filtered or unexported fields
}

ReadHTTPResponse implement of MessageReaderWithMethod

func NewReadHTTPPbResponse added in v0.4.0

func NewReadHTTPPbResponse(svc *descriptor.ServiceDescriptor, pbSvc proto.ServiceDescriptor) *ReadHTTPPbResponse

NewReadHTTPResponse ... Base64 encoding for binary is enabled by default.

func (*ReadHTTPPbResponse) Read added in v0.4.0

func (r *ReadHTTPPbResponse) Read(ctx context.Context, method string, in thrift.TProtocol) (interface{}, error)

Read ...

type ReadHTTPResponse

type ReadHTTPResponse struct {
	// contains filtered or unexported fields
}

ReadHTTPResponse implement of MessageReaderWithMethod

func NewReadHTTPResponse

func NewReadHTTPResponse(svc *descriptor.ServiceDescriptor) *ReadHTTPResponse

NewReadHTTPResponse ... Base64 encoding for binary is enabled by default.

func (*ReadHTTPResponse) Read

func (r *ReadHTTPResponse) Read(ctx context.Context, method string, in thrift.TProtocol) (interface{}, error)

Read ...

func (*ReadHTTPResponse) SetBase64Binary added in v0.1.3

func (r *ReadHTTPResponse) SetBase64Binary(enable bool)

SetBase64Binary enable/disable Base64 encoding for binary. Note that this method is not concurrent-safe.

func (*ReadHTTPResponse) SetDynamicGo added in v0.7.0

func (r *ReadHTTPResponse) SetDynamicGo(convOpts *conv.Options, msg remote.Message)

SetDynamicGo ...

func (*ReadHTTPResponse) SetUseRawBodyForHTTPResp added in v0.7.0

func (r *ReadHTTPResponse) SetUseRawBodyForHTTPResp(useRawBodyForHTTPResp bool)

SetUseRawBodyForHTTPResp ...

type ReadJSON added in v0.0.5

type ReadJSON struct {
	// contains filtered or unexported fields
}

ReadJSON implement of MessageReaderWithMethod

func NewReadJSON added in v0.0.5

func NewReadJSON(svc *descriptor.ServiceDescriptor, isClient bool) *ReadJSON

NewReadJSON build ReadJSON according to ServiceDescriptor

func (*ReadJSON) Read added in v0.0.5

func (m *ReadJSON) Read(ctx context.Context, method string, in thrift.TProtocol) (interface{}, error)

Read read data from in thrift.TProtocol and convert to json string

func (*ReadJSON) SetBinaryWithBase64 added in v0.1.3

func (m *ReadJSON) SetBinaryWithBase64(enable bool)

SetBinaryWithBase64 enable/disable Base64 encoding for binary. Note that this method is not concurrent-safe.

func (*ReadJSON) SetDynamicGo added in v0.7.0

func (m *ReadJSON) SetDynamicGo(convOpts, convOptsWithException *conv.Options, msg remote.Message)

SetDynamicGo ...

type ReadStruct

type ReadStruct struct {
	// contains filtered or unexported fields
}

ReadStruct implement of MessageReaderWithMethod

func NewReadStruct

func NewReadStruct(svc *descriptor.ServiceDescriptor, isClient bool) *ReadStruct

NewReadStruct ...

func NewReadStructForJSON added in v0.4.3

func NewReadStructForJSON(svc *descriptor.ServiceDescriptor, isClient bool) *ReadStruct

func (*ReadStruct) Read

func (m *ReadStruct) Read(ctx context.Context, method string, in thrift.TProtocol) (interface{}, error)

Read ...

func (*ReadStruct) SetBinaryOption added in v0.8.0

func (m *ReadStruct) SetBinaryOption(base64, byteSlice bool)

SetBinaryOption enable/disable Base64 encoding or returning []byte for binary. Note that this method is not concurrent-safe.

type TrafficEnv

type TrafficEnv struct {
	Open bool `thrift:"Open,1" json:"Open"`

	Env string `thrift:"Env,2" json:"Env"`
}
var Base_TrafficEnv_DEFAULT *TrafficEnv

func NewTrafficEnv

func NewTrafficEnv() *TrafficEnv

func (*TrafficEnv) GetEnv

func (p *TrafficEnv) GetEnv() string

func (*TrafficEnv) GetOpen

func (p *TrafficEnv) GetOpen() bool

func (*TrafficEnv) Read

func (p *TrafficEnv) Read(iprot thrift.TProtocol) (err error)

func (*TrafficEnv) ReadField1

func (p *TrafficEnv) ReadField1(iprot thrift.TProtocol) error

func (*TrafficEnv) ReadField2

func (p *TrafficEnv) ReadField2(iprot thrift.TProtocol) error

func (*TrafficEnv) SetEnv

func (p *TrafficEnv) SetEnv(val string)

func (*TrafficEnv) SetOpen

func (p *TrafficEnv) SetOpen(val bool)

func (*TrafficEnv) String

func (p *TrafficEnv) String() string

func (*TrafficEnv) Write

func (p *TrafficEnv) Write(oprot thrift.TProtocol) (err error)

type WriteHTTPPbRequest added in v0.4.0

type WriteHTTPPbRequest struct {
	// contains filtered or unexported fields
}

WriteHTTPPbRequest implement of MessageWriter

func NewWriteHTTPPbRequest added in v0.4.0

func NewWriteHTTPPbRequest(svc *descriptor.ServiceDescriptor, pbSvc *desc.ServiceDescriptor) *WriteHTTPPbRequest

NewWriteHTTPPbRequest ... Base64 decoding for binary is enabled by default.

func (*WriteHTTPPbRequest) Write added in v0.4.0

func (w *WriteHTTPPbRequest) Write(ctx context.Context, out thrift.TProtocol, msg interface{}, requestBase *Base) error

Write ...

type WriteHTTPRequest

type WriteHTTPRequest struct {
	// contains filtered or unexported fields
}

WriteHTTPRequest implement of MessageWriter

func NewWriteHTTPRequest

func NewWriteHTTPRequest(svc *descriptor.ServiceDescriptor) *WriteHTTPRequest

NewWriteHTTPRequest ... Base64 decoding for binary is enabled by default.

func (*WriteHTTPRequest) SetBinaryWithBase64 added in v0.1.3

func (w *WriteHTTPRequest) SetBinaryWithBase64(enable bool)

SetBinaryWithBase64 enable/disable Base64 decoding for binary. Note that this method is not concurrent-safe.

func (*WriteHTTPRequest) SetDynamicGo added in v0.7.0

func (w *WriteHTTPRequest) SetDynamicGo(convOpts, convOptsWithThriftBase *conv.Options, method string) error

SetDynamicGo ...

func (*WriteHTTPRequest) Write

func (w *WriteHTTPRequest) Write(ctx context.Context, out thrift.TProtocol, msg interface{}, requestBase *Base) error

Write ...

type WriteJSON added in v0.0.5

type WriteJSON struct {
	// contains filtered or unexported fields
}

WriteJSON implement of MessageWriter

func NewWriteJSON added in v0.0.5

func NewWriteJSON(svc *descriptor.ServiceDescriptor, method string, isClient bool) (*WriteJSON, error)

NewWriteJSON build WriteJSON according to ServiceDescriptor

func (*WriteJSON) SetBase64Binary added in v0.1.3

func (m *WriteJSON) SetBase64Binary(enable bool)

SetBase64Binary enable/disable Base64 decoding for binary. Note that this method is not concurrent-safe.

func (*WriteJSON) SetDynamicGo added in v0.7.0

func (m *WriteJSON) SetDynamicGo(svc *descriptor.ServiceDescriptor, method string, convOpts, convOptsWithThriftBase *conv.Options) error

SetDynamicGo ...

func (*WriteJSON) Write added in v0.0.5

func (m *WriteJSON) Write(ctx context.Context, out thrift.TProtocol, msg interface{}, requestBase *Base) error

Write write json string to out thrift.TProtocol

type WriteStruct

type WriteStruct struct {
	// contains filtered or unexported fields
}

WriteStruct implement of MessageWriter

func NewWriteStruct

func NewWriteStruct(svc *descriptor.ServiceDescriptor, method string, isClient bool) (*WriteStruct, error)

NewWriteStruct ...

func (*WriteStruct) SetBinaryWithBase64 added in v0.7.0

func (m *WriteStruct) SetBinaryWithBase64(enable bool)

SetBinaryWithBase64 enable/disable Base64 decoding for binary. Note that this method is not concurrent-safe.

func (*WriteStruct) Write

func (m *WriteStruct) Write(ctx context.Context, out thrift.TProtocol, msg interface{}, requestBase *Base) error

Write ...

Jump to

Keyboard shortcuts

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