Documentation ¶
Overview ¶
Package thrift contains an implementation of Apache Thrift.
Index ¶
- Constants
- Variables
- func NewTProtocolExceptionFromError(err error) error
- func NewTTransportExceptionFromError(err error) error
- func Skip(v TType, p TProtocol) (err error)
- type TApplicationError
- type TApplicationException
- type TClient
- type TConfiguration
- func (cfg *TConfiguration) CheckSizeForProtocol(size int) error
- func (cfg *TConfiguration) GetMaxBufferSize() int
- func (cfg *TConfiguration) GetMaxMessageSize() int
- func (cfg *TConfiguration) IsStrictRead() bool
- func (cfg *TConfiguration) IsStrictWrite() bool
- func (cfg *TConfiguration) NonNil() *TConfiguration
- func (cfg *TConfiguration) Propagate(impls ...interface{})
- type TConfigurationSetter
- type TExtraTransport
- type TFieldHeader
- type TFlusher
- type THttpClient
- func (c *THttpClient) DelHeader(k string)
- func (c *THttpClient) Flush(ctx context.Context) (err error)
- func (c *THttpClient) Read(v []byte) (int, error)
- func (c *THttpClient) ReadByte() (byte, error)
- func (c *THttpClient) SetHeader(k, v string)
- func (c *THttpClient) Write(v []byte) (int, error)
- func (c *THttpClient) WriteByte(v byte) error
- type THttpClientFactory
- type THttpClientOptions
- type TListHeader
- type TMapHeader
- type TMemoryBuffer
- type TMessageHeader
- type TMessageType
- type TPoolClient
- type TProtocol
- type TProtocolError
- type TProtocolException
- type TProtocolFactory
- type TSetHeader
- type TStandardClient
- type TStruct
- type TStructHeader
- type TTransport
- type TTransportError
- type TTransportException
- type TTransportFactory
- type TType
Constants ¶
const ( DefaultMaxBufferSize = 1024 DefaultMaxMessageSize = 8192 )
Variables ¶
var DefaultTConfiguration = &TConfiguration{ StrictWrite: true, MaxBufferSize: DefaultMaxBufferSize, MaxMessageSize: DefaultMaxMessageSize, }
DefaultTConfiguration default TConfiguration.
Functions ¶
func NewTProtocolExceptionFromError ¶
NewTProtocolExceptionFromError returns new TProtocolException. it will returns nil if given err is nil.
func NewTTransportExceptionFromError ¶
NewTTransportExceptionFromError returns new TTransportException. it will returns nil if given err is nil.
Types ¶
type TApplicationError ¶
type TApplicationError = int32
TApplicationError kind of TApplicationException.
const ( TApplicationErrorUnknown TApplicationError = iota TApplicationErrorUnknownMethod TApplicationErrorInvalidMessageType TApplicationErrorWrongMethodName TApplicationErrorBadSequenceID TApplicationErrorMissingResult TApplicationErrorInternalError TApplicationErrorProtocolError TApplicationErrorInvalidTransform TApplicationErrorInvalidProtocol TApplicationErrorUnsupportedClientType )
type TApplicationException ¶
type TApplicationException struct { Message string `thrift:"1"` Type TApplicationError `thrift:"2"` }
TApplicationException an application-level exception.
func (*TApplicationException) Error ¶
func (e *TApplicationException) Error() string
Error returns a error message.
func (*TApplicationException) Read ¶
func (e *TApplicationException) Read(p TProtocol) (err error)
Read reads values from p.
func (*TApplicationException) Write ¶
func (e *TApplicationException) Write(p TProtocol) (err error)
Write writes values to p.
type TClient ¶
type TClient interface { // Call writes a message. Call(ctx context.Context, method string, args, result TStruct) (err error) }
TClient is interface that wraps Call method.
type TConfiguration ¶
TConfiguration a shared configuration between an implementations.
func (*TConfiguration) CheckSizeForProtocol ¶
func (cfg *TConfiguration) CheckSizeForProtocol(size int) error
CheckSizeForProtocol returns TProtocolException if size is not valid.
func (*TConfiguration) GetMaxBufferSize ¶
func (cfg *TConfiguration) GetMaxBufferSize() int
GetMaxBufferSize returns max buffer size. will returns DefaultMaxBufferSize if cfg.MaxBufferSize < 1.
func (*TConfiguration) GetMaxMessageSize ¶
func (cfg *TConfiguration) GetMaxMessageSize() int
GetMaxMessageSize returns max message size. will returns DefaultMaxMessageSize if cfg.MaxMessageSize < 1.
func (*TConfiguration) IsStrictRead ¶
func (cfg *TConfiguration) IsStrictRead() bool
IsStrictRead returns protocol strict read configuration.
func (*TConfiguration) IsStrictWrite ¶
func (cfg *TConfiguration) IsStrictWrite() bool
IsStrictWrite returns protocol strict write configuration.
func (*TConfiguration) NonNil ¶
func (cfg *TConfiguration) NonNil() *TConfiguration
NonNil returns DefaultTConfiguration if cfg is nil.
func (*TConfiguration) Propagate ¶
func (cfg *TConfiguration) Propagate(impls ...interface{})
Propagate propagates cfg to impls. if cfg is nil. DefaultTConfiguration will used instead.
type TConfigurationSetter ¶
type TConfigurationSetter interface {
SetTConfiguration(cfg *TConfiguration)
}
TConfigurationSetter is interface that wraps SetTConfiguration method.
type TExtraTransport ¶
type TExtraTransport interface { TTransport io.ByteReader io.ByteWriter }
TExtraTransport enhanced version of TTransport
func NewTExtraTransport ¶
func NewTExtraTransport(t TTransport, cfg *TConfiguration) TExtraTransport
NewTExtraTransport wraps t to TExtraTransport.
type TFieldHeader ¶
TFieldHeader field header.
type TFlusher ¶
TFlusher interface that wraps Flush method which allows to flush underlying buffer. it implemented by TTransport and TProtocol.
type THttpClient ¶
type THttpClient struct {
// contains filtered or unexported fields
}
THttpClient a http client implementation for TTransport.
func NewTHttpClient ¶
func NewTHttpClient(urlstr string) (*THttpClient, error)
NewTHttpClient returns new THttpClient.
func NewTHttpClientWithOptions ¶
func NewTHttpClientWithOptions(urlstr string, options THttpClientOptions) (*THttpClient, error)
NewTHttpClientWithOptions returns new THttpClient with options.
func (*THttpClient) DelHeader ¶
func (c *THttpClient) DelHeader(k string)
DelHeader delete a http header.
func (*THttpClient) Flush ¶
func (c *THttpClient) Flush(ctx context.Context) (err error)
Flush sends request to server.
func (*THttpClient) Read ¶
func (c *THttpClient) Read(v []byte) (int, error)
Read reads v from response body.
func (*THttpClient) ReadByte ¶
func (c *THttpClient) ReadByte() (byte, error)
ReadByte reads next one byte from response body.
func (*THttpClient) SetHeader ¶
func (c *THttpClient) SetHeader(k, v string)
SetHeader set a http header.
func (*THttpClient) Write ¶
func (c *THttpClient) Write(v []byte) (int, error)
Write writes v to request buffer.
func (*THttpClient) WriteByte ¶
func (c *THttpClient) WriteByte(v byte) error
WriteByte writes v to request buffer.
type THttpClientFactory ¶
type THttpClientFactory struct {
// contains filtered or unexported fields
}
THttpClientFactory a factory of THttpClient.
func NewTHttpClientFactory ¶
func NewTHttpClientFactory(urlstr string) *THttpClientFactory
NewTHttpClientFactory returns new THttpClientFactory.
func NewTHttpClientFactoryWithOptions ¶
func NewTHttpClientFactoryWithOptions(urlstr string, options THttpClientOptions) *THttpClientFactory
NewTHttpClientFactoryWithOptions returns new THttpClientFactory with options.
func (*THttpClientFactory) GetTransport ¶
func (f *THttpClientFactory) GetTransport(t TTransport) (TTransport, error)
GetTransport returns new THttpClient.
type THttpClientOptions ¶
THttpClientOptions an optional configurations for THttpClient.
func NewDefaultTHttpClientOptions ¶ added in v0.0.3
func NewDefaultTHttpClientOptions() THttpClientOptions
NewDefaultTHttpClientOptions returns new default THttpClientOptions.
type TMemoryBuffer ¶
TMemoryBuffer memory buffer-based implementation for TTransport.
func NewTMemoryBuffer ¶
func NewTMemoryBuffer() *TMemoryBuffer
NewTMemoryBuffer returns new empty TMemoryBuffer.
type TMessageHeader ¶
type TMessageHeader struct { Name string Type TMessageType Identity int32 }
TMessageHeader message header.
type TMessageType ¶
type TMessageType = byte
TMessageType type of message used in TMessageHeader.
const ( CALL TMessageType = iota + 1 REPLY EXCEPTION ONEWAY )
type TPoolClient ¶
type TPoolClient struct {
// contains filtered or unexported fields
}
TPoolClient concurrency implementation of TStandardClient.
func NewTPoolClient ¶
func NewTPoolClient(itrans, otrans TTransportFactory, iprot, oprot TProtocolFactory) *TPoolClient
NewTPoolClient returns new TPoolClient.
type TProtocol ¶
type TProtocol interface { TFlusher WriteMessageBegin(h TMessageHeader) (err error) WriteMessageEnd() (err error) WriteStructBegin(h TStructHeader) (err error) WriteStructEnd() (err error) WriteFieldBegin(h TFieldHeader) (err error) WriteFieldEnd() (err error) WriteFieldStop() (err error) WriteMapBegin(h TMapHeader) (err error) WriteMapEnd() (err error) WriteSetBegin(h TSetHeader) (err error) WriteSetEnd() (err error) WriteListBegin(h TListHeader) (err error) WriteListEnd() (err error) WriteBool(v bool) (err error) WriteByte(v byte) (err error) WriteDouble(v float64) (err error) WriteU16(v uint16) (err error) WriteI16(v int16) (err error) WriteU32(v uint32) (err error) WriteI32(v int32) (err error) WriteU64(v uint64) (err error) WriteI64(v int64) (err error) WriteString(v string) (err error) WriteBinary(v []byte) (err error) ReadMessageBegin() (h TMessageHeader, err error) ReadMessageEnd() (err error) ReadStructBegin() (h TStructHeader, err error) ReadStructEnd() (err error) ReadFieldBegin() (h TFieldHeader, err error) ReadFieldEnd() (err error) ReadMapBegin() (h TMapHeader, err error) ReadMapEnd() (err error) ReadSetBegin() (h TSetHeader, err error) ReadSetEnd() (err error) ReadListBegin() (h TListHeader, err error) ReadListEnd() (err error) ReadBool() (v bool, err error) ReadByte() (v byte, err error) ReadDouble() (v float64, err error) ReadU16() (v uint16, err error) ReadI16() (v int16, err error) ReadU32() (v uint32, err error) ReadI32() (v int32, err error) ReadU64() (v uint64, err error) ReadI64() (v int64, err error) ReadString() (v string, err error) ReadBinary() (v []byte, err error) Skip(v TType) (err error) }
TProtocol an interface that contains read/write value methods. it also implement TFlusher which allow to flush buffered buffer.
func NewTBinaryProtocol ¶
func NewTBinaryProtocol(t TTransport, cfg *TConfiguration) TProtocol
NewTBinaryProtocol returns new binary protocol.
func NewTCompactProtocol ¶ added in v0.0.2
func NewTCompactProtocol(t TTransport, cfg *TConfiguration) TProtocol
NewTCompactProtocol returns new compact protocol.
type TProtocolError ¶
type TProtocolError byte
TProtocolError kind of TProtocolException.
const ( TProtocolErrorUnknown TProtocolError = iota TProtocolErrorInvalidData TProtocolErrorNegativeSize TProtocolErrorSizeLimit TProtocolErrorBadVersion )
type TProtocolException ¶
type TProtocolException struct {
// contains filtered or unexported fields
}
TProtocolException a protocol-level exception.
func NewTProtocolException ¶
func NewTProtocolException(k TProtocolError, text string) *TProtocolException
NewTProtocolException returns new TProtocolException.
func (*TProtocolException) Error ¶
func (e *TProtocolException) Error() string
Error returns error message.
func (*TProtocolException) Kind ¶
func (e *TProtocolException) Kind() TProtocolError
Kind returns kind of TProtocolException.
func (*TProtocolException) Unwrap ¶
func (e *TProtocolException) Unwrap() error
Unwrap returns holding error.
type TProtocolFactory ¶
type TProtocolFactory interface { // GetProtocol retursn new TTransport. GetProtocol(t TTransport) (p TProtocol) }
TProtocolFactory a factory of TProtocol.
func NewTBinaryProtocolFactory ¶
func NewTBinaryProtocolFactory(cfg *TConfiguration) TProtocolFactory
NewTBinaryProtocolFactory returns new TProtocolFactory of NewTBinaryProtocol.
func NewTCompactProtocolFactory ¶ added in v0.0.2
func NewTCompactProtocolFactory(cfg *TConfiguration) TProtocolFactory
NewTCompactProtocolFactory returns new TProtocolFactory of NewtCompactProtocol.
type TStandardClient ¶
type TStandardClient struct {
// contains filtered or unexported fields
}
TStandardClient an implementation of TClient.
func NewTStandardClient ¶
func NewTStandardClient(iprot, oprot TProtocol) *TStandardClient
NewTStandardClient returns new TStandardClient.
type TStruct ¶
type TStruct interface { // Read reads value from p. Read(p TProtocol) (err error) // Write writes value to p. Write(p TProtocol) (err error) }
TStruct is interface that wraps Read and Write methods.
type TTransport ¶
type TTransport interface { io.ReadWriter TFlusher }
TTransport interface that groups io.ReadWriter and Flusher. it should be used by TProtocol
type TTransportError ¶
type TTransportError byte
TTransportError kind of TTransportException.
const ( TTransportErrorUnknown TTransportError = iota TTransportErrorEOF TTransportErrorTimeout )
type TTransportException ¶
type TTransportException struct {
// contains filtered or unexported fields
}
TTransportException a transport-level exception.
func NewTTransportException ¶
func NewTTransportException(k TTransportError, text string) *TTransportException
NewTTransportException returns new TTransportException.
func (*TTransportException) Error ¶
func (e *TTransportException) Error() string
Error returns error message.
func (*TTransportException) Kind ¶
func (e *TTransportException) Kind() TTransportError
Kind returns kind of TTransportException.
func (*TTransportException) Timeout ¶
func (e *TTransportException) Timeout() bool
Timeout returns true if is timeout error.
func (*TTransportException) Unwrap ¶
func (e *TTransportException) Unwrap() error
Unwrap returns holding error.
type TTransportFactory ¶
type TTransportFactory interface { // GetTransport returns new TTransport. GetTransport(t TTransport) (TTransport, error) }
TTransportFactory a factory of TTransport.