Documentation ¶
Overview ¶
Package thrift provides thrift idl parser and codec for generic call
Index ¶
- func Parse(tree *parser.Thrift, mode ParseMode, opts ...ParseOption) (*descriptor.ServiceDescriptor, error)
- func SetDefaultParseMode(m ParseMode)
- type Base
- type BaseResp
- type HTTPPbReaderWriter
- type HTTPReaderWriter
- type JSONReaderWriter
- type MessageReader
- type MessageWriter
- type MsgType
- type ParseMode
- type ParseOption
- type ReadHTTPPbResponse
- type ReadHTTPResponse
- func (r *ReadHTTPResponse) Read(ctx context.Context, method string, isClient bool, dataLen int, ...) (interface{}, error)
- func (r *ReadHTTPResponse) SetBase64Binary(enable bool)
- func (r *ReadHTTPResponse) SetDynamicGo(convOpts *conv.Options)
- func (r *ReadHTTPResponse) SetUseRawBodyForHTTPResp(useRawBodyForHTTPResp bool)
- type ReadJSON
- type ReadStruct
- type StructReaderWriter
- type WriteBinary
- type WriteHTTPPbRequest
- type WriteHTTPRequest
- type WriteJSON
- type WriteStruct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
func Parse(tree *parser.Thrift, mode ParseMode, opts ...ParseOption) (*descriptor.ServiceDescriptor, error)
Parse descriptor from parser.Thrift
func SetDefaultParseMode ¶ added in v0.1.0
func SetDefaultParseMode(m ParseMode)
SetDefaultParseMode sets the default parse mode.
Types ¶
type BaseResp ¶
BaseResp ... Deprecated: use github.com/cloudwego/gopkg/protocol/thrift/base
func NewBaseResp ¶
func NewBaseResp() *BaseResp
NewBaseResp ... Deprecated: use github.com/cloudwego/gopkg/protocol/thrift/base
type HTTPPbReaderWriter ¶ added in v0.11.0
type HTTPPbReaderWriter struct { *ReadHTTPPbResponse *WriteHTTPPbRequest }
func NewHTTPPbReaderWriter ¶ added in v0.11.0
func NewHTTPPbReaderWriter(svc *descriptor.ServiceDescriptor, pbsvc proto.ServiceDescriptor) *HTTPPbReaderWriter
type HTTPReaderWriter ¶ added in v0.11.0
type HTTPReaderWriter struct { *ReadHTTPResponse *WriteHTTPRequest }
func NewHTTPReaderWriter ¶ added in v0.11.0
func NewHTTPReaderWriter(svc *descriptor.ServiceDescriptor) *HTTPReaderWriter
type JSONReaderWriter ¶ added in v0.11.0
func NewJsonReaderWriter ¶ added in v0.11.0
func NewJsonReaderWriter(svc *descriptor.ServiceDescriptor) *JSONReaderWriter
type MessageReader ¶
type MessageReader interface {
Read(ctx context.Context, method string, isClient bool, dataLen int, in bufiox.Reader) (interface{}, error)
}
MessageReader read from thrift.TProtocol with method
type MessageWriter ¶
type MessageWriter interface {
Write(ctx context.Context, out bufiox.Writer, msg interface{}, method string, isClient bool, requestBase *base.Base) error
}
MessageWriter write to thrift.TProtocol
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 ParseOption ¶ added in v0.12.0
type ParseOption struct {
F func(opt *parseOptions)
}
func WithGoTagDisabled ¶ added in v0.12.0
func WithGoTagDisabled(disable bool) ParseOption
type ReadHTTPPbResponse ¶ added in v0.4.0
type ReadHTTPPbResponse struct {
// contains filtered or unexported fields
}
ReadHTTPPbResponse implement of MessageReaderWithMethod
func NewReadHTTPPbResponse ¶ added in v0.4.0
func NewReadHTTPPbResponse(svc *descriptor.ServiceDescriptor, pbSvc proto.ServiceDescriptor) *ReadHTTPPbResponse
NewReadHTTPPbResponse ... Base64 encoding for binary is enabled by default.
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, isClient bool, dataLen int, in bufiox.Reader) (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)
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) *ReadJSON
NewReadJSON build ReadJSON according to ServiceDescriptor
func (*ReadJSON) Read ¶ added in v0.0.5
func (m *ReadJSON) Read(ctx context.Context, method string, isClient bool, dataLen int, in bufiox.Reader) (interface{}, error)
Read read data from in thrift.TProtocol and convert to json string
func (*ReadJSON) SetBinaryWithBase64 ¶ added in v0.1.3
SetBinaryWithBase64 enable/disable Base64 encoding for binary. Note that this method is not concurrent-safe.
func (*ReadJSON) SetDynamicGo ¶ added in v0.7.0
SetDynamicGo ...
type ReadStruct ¶
type ReadStruct struct {
// contains filtered or unexported fields
}
ReadStruct implement of MessageReaderWithMethod
func NewReadStruct ¶
func NewReadStruct(svc *descriptor.ServiceDescriptor) *ReadStruct
NewReadStruct ...
func NewReadStructForJSON ¶ added in v0.4.3
func NewReadStructForJSON(svc *descriptor.ServiceDescriptor) *ReadStruct
func (*ReadStruct) Read ¶
func (m *ReadStruct) Read(ctx context.Context, method string, isClient bool, dataLen int, in bufiox.Reader) (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.
func (*ReadStruct) SetSetFieldsForEmptyStruct ¶ added in v0.9.1
func (m *ReadStruct) SetSetFieldsForEmptyStruct(mode uint8)
SetBinaryOption enable/disable set all fields in map-generic even if a struct is empty
mode == 0 means disable mode == 1 means only set required and default fields mode == 2 means set all fields
type StructReaderWriter ¶ added in v0.11.0
type StructReaderWriter struct { *ReadStruct *WriteStruct }
func NewStructReaderWriter ¶ added in v0.11.0
func NewStructReaderWriter(svc *descriptor.ServiceDescriptor) *StructReaderWriter
func NewStructReaderWriterForJSON ¶ added in v0.11.0
func NewStructReaderWriterForJSON(svc *descriptor.ServiceDescriptor) *StructReaderWriter
type WriteBinary ¶ added in v0.11.0
type WriteBinary struct{}
WriteBinary implement of MessageWriter
func NewWriteBinary ¶ added in v0.11.0
func NewWriteBinary() *WriteBinary
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.
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)
SetDynamicGo ...
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) *WriteJSON
NewWriteJSON build WriteJSON according to ServiceDescriptor
func (*WriteJSON) SetBase64Binary ¶ added in v0.1.3
SetBase64Binary enable/disable Base64 decoding for binary. Note that this method is not concurrent-safe.
func (*WriteJSON) SetDynamicGo ¶ added in v0.7.0
SetDynamicGo ...
type WriteStruct ¶
type WriteStruct struct {
// contains filtered or unexported fields
}
WriteStruct implement of MessageWriter
func NewWriteStruct ¶
func NewWriteStruct(svc *descriptor.ServiceDescriptor) *WriteStruct
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.