thrift

package
v0.0.0-...-ecdee35 Latest Latest
Warning

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

Go to latest
Published: May 9, 2016 License: BSD-3-Clause Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
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

View Source
const (
	MessageTypeCall      = 1
	MessageTypeReply     = 2
	MessageTypeException = 3
	MessageTypeOneway    = 4
)

Message types for RPC

View Source
const (
	ExceptionUnknown            = 0
	ExceptionUnknownMethod      = 1
	ExceptionInvalidMessageType = 2
	ExceptionWrongMethodName    = 3
	ExceptionBadSequenceID      = 4
	ExceptionMissingResult      = 5
	ExceptionInternalError      = 6
	ExceptionProtocolError      = 7
)

Exception types for RPC responses

View Source
const (
	// DefaultMaxFrameSize is the default max size for frames when using the FramedReadWriteCloser
	DefaultMaxFrameSize = 1024 * 1024
)

Variables

View Source
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")
)
View Source
var (
	ErrUnimplemented = errors.New("thrift: unimplemented")
)
View Source
var TypeNames = map[int]string{
	TypeStop:   "stop",
	TypeVoid:   "void",
	TypeBool:   "bool",
	TypeByte:   "byte",
	TypeDouble: "double",
	TypeI16:    "i16",
	TypeI32:    "i32",
	TypeI64:    "i64",
	TypeString: "string",
	TypeStruct: "struct",
	TypeMap:    "map",
	TypeSet:    "set",
	TypeList:   "list",
	TypeUtf8:   "utf8",
	TypeUtf16:  "utf16",
}

Functions

func Bool

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func Byte

func Byte(v byte) *byte

Byte is a helper routine that allocates a new byte value to store v and returns a pointer to it.

func CamelCase

func CamelCase(s string) string

CamelCase returns the string converted to camel case (e.g. some_name to SomeName)

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

func Float32(v float32) *float32

Float32 is a helper routine that allocates a new float32 value to store v and returns a pointer to it.

func Float64

func Float64(v float64) *float64

Float64 is a helper routine that allocates a new float64 value to store v and returns a pointer to it.

func Int16

func Int16(v int16) *int16

Int16 is a helper routine that allocates a new int16 value to store v and returns a pointer to it.

func Int32

func Int32(v int32) *int32

Int32 is a helper routine that allocates a new int32 value to store v and returns a pointer to it.

func Int64

func Int64(v int64) *int64

Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it.

func NewClient

func NewClient(conn Transport, supportOnewayRequests bool) *rpc.Client

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

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

Types

type ApplicationException

type ApplicationException struct {
	Message string `thrift:"1"`
	Type    int32  `thrift:"2"`
}

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 Flusher

type Flusher interface {
	Flush() error
}

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) Read

func (f *FramedReadWriteCloser) Read(p []byte) (int, error)

func (*FramedReadWriteCloser) ReadByte

func (f *FramedReadWriteCloser) ReadByte() (byte, error)

func (*FramedReadWriteCloser) Write

func (f *FramedReadWriteCloser) Write(p []byte) (int, error)

type InvalidValueError

type InvalidValueError struct {
	Value reflect.Value
	Str   string
}

func (*InvalidValueError) Error

func (e *InvalidValueError) Error() string

type MissingRequiredField

type MissingRequiredField struct {
	StructName string
	FieldName  string
}

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

type ProtocolError struct {
	Protocol string
	Message  string
}

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

type UnsupportedTypeError struct {
	Type reflect.Type
}

func (*UnsupportedTypeError) Error

func (e *UnsupportedTypeError) Error() string

type UnsupportedValueError

type UnsupportedValueError struct {
	Value reflect.Value
	Str   string
}

func (*UnsupportedValueError) Error

func (e *UnsupportedValueError) Error() string

Jump to

Keyboard shortcuts

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