Documentation ¶
Index ¶
- Constants
- Variables
- func Bool(v bool) *bool
- func Byte(v byte) *byte
- func CamelCase(s string) string
- func DecodeStruct(r ProtocolReader, v interface{}) (err error)
- func Dial(network, address string, framed bool, protocol ProtocolBuilder, ...) (*rpc.Client, error)
- func EncodeStruct(w ProtocolWriter, v interface{}) (err error)
- func Float32(v float32) *float32
- func Float64(v float64) *float64
- func Int16(v int16) *int16
- func Int32(v int32) *int32
- func Int64(v int64) *int64
- func NewClient(conn Transport, supportOnewayRequests bool) *rpc.Client
- func NewClientCodec(conn Transport, supportOnewayRequests bool) rpc.ClientCodec
- func NewServerCodec(conn Transport) rpc.ServerCodec
- func ReadValue(r ProtocolReader, thriftType byte) (interface{}, error)
- func ServeConn(conn Transport)
- func SkipValue(r ProtocolReader, thriftType byte) error
- func String(v string) *string
- type ApplicationException
- type Decoder
- type Encoder
- type ErrFrameTooBig
- type Flusher
- type FramedReadWriteCloser
- type MissingRequiredField
- type ProtocolBuilder
- type ProtocolError
- type ProtocolReadWriter
- type ProtocolReader
- type ProtocolWriter
- type Transport
- type UnsupportedTypeError
- type UnsupportedValueError
Constants ¶
const ( TypeStop = 0 TypeVoid = 1 TypeBool = 2 TypeByte = 3 TypeI08 = 3 TypeDouble = 4 TypeI16 = 6 TypeI32 = 8 TypeI64 = 10 TypeString = 11 TypeUtf7 = 11 TypeStruct = 12 TypeMap = 13 TypeSet = 14 TypeList = 15 TypeUtf8 = 16 TypeUtf16 = 17 )
Type identifiers for serialized Thrift
const ( MessageTypeCall = 1 MessageTypeReply = 2 MessageTypeException = 3 MessageTypeOneway = 4 )
Message types for RPC
const ( ExceptionUnknown = 0 ExceptionUnknownMethod = 1 ExceptionInvalidMessageType = 2 ExceptionWrongMethodName = 3 ExceptionBadSequenceID = 4 ExceptionMissingResult = 5 ExceptionInternalError = 6 ExceptionProtocolError = 7 )
Exception types for RPC responses
const (
// DefaultMaxFrameSize is the default max size for frames when using the FramedReadWriteCloser
DefaultMaxFrameSize = 1024 * 1024
)
Variables ¶
var ( // ErrTooManyPendingRequests is the error when there's too many requests that have been // sent that have not yet received responses. ErrTooManyPendingRequests = errors.New("thrift.client: too many pending requests") // ErrOnewayNotEnabled is the error when trying to make a one-way RPC call but the // client was not created with one-way support enabled. ErrOnewayNotEnabled = errors.New("thrift.client: one way support not enabled on codec") )
var BinaryProtocol = NewProtocolBuilder( func(r io.Reader) ProtocolReader { return NewBinaryProtocolReader(r, false) }, func(w io.Writer) ProtocolWriter { return NewBinaryProtocolWriter(w, true) }, )
var CompactProtocol = NewProtocolBuilder(NewCompactProtocolReader, NewCompactProtocolWriter)
var (
ErrUnimplemented = errors.New("thrift: unimplemented")
)
Functions ¶
func Bool ¶
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
func Byte ¶
Byte is a helper routine that allocates a new byte value to store v and returns a pointer to it.
func DecodeStruct ¶
func DecodeStruct(r ProtocolReader, v interface{}) (err error)
DecodeStruct tries to deserialize a struct from a Thrift stream
func Dial ¶
func Dial(network, address string, framed bool, protocol ProtocolBuilder, supportOnewayRequests bool) (*rpc.Client, error)
Dial connects to a Thrift RPC server at the specified network address using the specified protocol.
func EncodeStruct ¶
func EncodeStruct(w ProtocolWriter, v interface{}) (err error)
EncodeStruct tries to serialize a struct to a Thrift stream
func Float32 ¶
Float32 is a helper routine that allocates a new float32 value to store v and returns a pointer to it.
func Float64 ¶
Float64 is a helper routine that allocates a new float64 value to store v and returns a pointer to it.
func Int16 ¶
Int16 is a helper routine that allocates a new int16 value to store v and returns a pointer to it.
func Int32 ¶
Int32 is a helper routine that allocates a new int32 value to store v and returns a pointer to it.
func Int64 ¶
Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it.
func NewClient ¶
NewClient returns a new rpc.Client to handle requests to the set of services at the other end of the connection.
func NewClientCodec ¶
func NewClientCodec(conn Transport, supportOnewayRequests bool) rpc.ClientCodec
NewClientCodec returns a new rpc.ClientCodec using Thrift RPC on conn using the specified protocol.
func NewServerCodec ¶
func NewServerCodec(conn Transport) rpc.ServerCodec
NewServerCodec returns a new rpc.ServerCodec using Thrift RPC on conn using the specified protocol.
func ReadValue ¶
func ReadValue(r ProtocolReader, thriftType byte) (interface{}, error)
func ServeConn ¶
func ServeConn(conn Transport)
ServeConn runs the Thrift RPC server on a single connection. ServeConn blocks, serving the connection until the client hangs up. The caller typically invokes ServeConn in a go statement.
func SkipValue ¶
func SkipValue(r ProtocolReader, thriftType byte) error
Types ¶
type ApplicationException ¶
ApplicationException is an application level thrift exception
func (*ApplicationException) String ¶
func (e *ApplicationException) String() string
type Decoder ¶
type Decoder interface {
DecodeThrift(ProtocolReader) error
}
Decoder is the interface that allows types to deserialize themselves from a Thrift stream
type Encoder ¶
type Encoder interface {
EncodeThrift(ProtocolWriter) error
}
Encoder is the interface that allows types to serialize themselves to a Thrift stream
type ErrFrameTooBig ¶
type ErrFrameTooBig struct {
Size, MaxSize int64
}
func (ErrFrameTooBig) Error ¶
func (e ErrFrameTooBig) Error() string
type FramedReadWriteCloser ¶
type FramedReadWriteCloser struct {
// contains filtered or unexported fields
}
func NewFramedReadWriteCloser ¶
func NewFramedReadWriteCloser(wrapped io.ReadWriteCloser, maxFrameSize int) *FramedReadWriteCloser
func (*FramedReadWriteCloser) Close ¶
func (f *FramedReadWriteCloser) Close() error
func (*FramedReadWriteCloser) Flush ¶
func (f *FramedReadWriteCloser) Flush() error
func (*FramedReadWriteCloser) ReadByte ¶
func (f *FramedReadWriteCloser) ReadByte() (byte, error)
type MissingRequiredField ¶
func (*MissingRequiredField) Error ¶
func (e *MissingRequiredField) Error() string
type ProtocolBuilder ¶
type ProtocolBuilder interface { NewProtocolReader(io.Reader) ProtocolReader NewProtocolWriter(io.Writer) ProtocolWriter }
func NewProtocolBuilder ¶
func NewProtocolBuilder(r func(io.Reader) ProtocolReader, w func(io.Writer) ProtocolWriter) ProtocolBuilder
type ProtocolError ¶
func (ProtocolError) Error ¶
func (e ProtocolError) Error() string
type ProtocolReadWriter ¶
type ProtocolReadWriter interface { ProtocolReader ProtocolWriter }
type ProtocolReader ¶
type ProtocolReader interface { ReadMessageBegin() (name string, messageType byte, seqid int32, err error) ReadMessageEnd() error ReadStructBegin() error ReadStructEnd() error ReadFieldBegin() (fieldType byte, id int16, err error) ReadFieldEnd() error ReadMapBegin() (keyType byte, valueType byte, size int, err error) ReadMapEnd() error ReadListBegin() (elementType byte, size int, err error) ReadListEnd() error ReadSetBegin() (elementType byte, size int, err error) ReadSetEnd() error ReadBool() (bool, error) ReadByte() (byte, error) ReadI16() (int16, error) ReadI32() (int32, error) ReadI64() (int64, error) ReadDouble() (float64, error) ReadString() (string, error) ReadBytes() ([]byte, error) }
func NewBinaryProtocolReader ¶
func NewBinaryProtocolReader(r io.Reader, strict bool) ProtocolReader
func NewCompactProtocolReader ¶
func NewCompactProtocolReader(r io.Reader) ProtocolReader
type ProtocolWriter ¶
type ProtocolWriter interface { WriteMessageBegin(name string, messageType byte, seqid int32) error WriteMessageEnd() error WriteStructBegin(name string) error WriteStructEnd() error WriteFieldBegin(name string, fieldType byte, id int16) error WriteFieldEnd() error WriteFieldStop() error WriteMapBegin(keyType byte, valueType byte, size int) error WriteMapEnd() error WriteListBegin(elementType byte, size int) error WriteListEnd() error WriteSetBegin(elementType byte, size int) error WriteSetEnd() error WriteBool(value bool) error WriteByte(value byte) error WriteI16(value int16) error WriteI32(value int32) error WriteI64(value int64) error WriteDouble(value float64) error WriteString(value string) error WriteBytes(value []byte) error }
func NewBinaryProtocolWriter ¶
func NewBinaryProtocolWriter(w io.Writer, strict bool) ProtocolWriter
func NewCompactProtocolWriter ¶
func NewCompactProtocolWriter(w io.Writer) ProtocolWriter
func NewTextProtocolWriter ¶
func NewTextProtocolWriter(w io.Writer) ProtocolWriter
type Transport ¶
type Transport interface { ProtocolReader ProtocolWriter io.Closer Flusher }
func NewTransport ¶
func NewTransport(rwc io.ReadWriteCloser, p ProtocolBuilder) Transport
type UnsupportedTypeError ¶
func (*UnsupportedTypeError) Error ¶
func (e *UnsupportedTypeError) Error() string
type UnsupportedValueError ¶
func (*UnsupportedValueError) Error ¶
func (e *UnsupportedValueError) Error() string