thrift

package
v0.0.0-...-fa2f347 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 23 Imported by: 7

README

Facebook Thrift Go

The files in this repository is only for the Go libraries of fbthrift, see facebook/fbthrift for the remaining code.

Documentation

Index

Constants

View Source
const (
	UNKNOWN_APPLICATION_EXCEPTION  = 0
	UNKNOWN_METHOD                 = 1
	INVALID_MESSAGE_TYPE_EXCEPTION = 2
	WRONG_METHOD_NAME              = 3
	BAD_SEQUENCE_ID                = 4
	MISSING_RESULT                 = 5
	INTERNAL_ERROR                 = 6
	PROTOCOL_ERROR                 = 7
)
View Source
const (
	COMPACT_PROTOCOL_ID       = 0x082
	COMPACT_VERSION           = 0x01
	COMPACT_VERSION_BE        = 0x02
	COMPACT_VERSION_MASK      = 0x1f
	COMPACT_TYPE_MASK         = 0x0E0
	COMPACT_TYPE_BITS         = 0x07
	COMPACT_TYPE_SHIFT_AMOUNT = 5
)
View Source
const (
	COMPACT_BOOLEAN_TRUE  = 0x01
	COMPACT_BOOLEAN_FALSE = 0x02
	COMPACT_BYTE          = 0x03
	COMPACT_I16           = 0x04
	COMPACT_I32           = 0x05
	COMPACT_I64           = 0x06
	COMPACT_DOUBLE        = 0x07
	COMPACT_BINARY        = 0x08
	COMPACT_LIST          = 0x09
	COMPACT_SET           = 0x0A
	COMPACT_MAP           = 0x0B
	COMPACT_STRUCT        = 0x0C
	COMPACT_FLOAT         = 0x0D
)
View Source
const (
	IdentityHeader       string = "identity"
	IDVersionHeader      string = "id_version"
	IDVersion            string = "1"
	PriorityHeader       string = "thrift_priority"
	ClientTimeoutHeader  string = "client_timeout"
	QueueTimeoutHeader   string = "queue_timeout"
	ClientMetadataHeader string = "client_metadata"
	ClientMetadata       string = "{\"agent\":\"headertransport.go\"}"
	// Header Magicks
	// 0 and 16th bits must be 0 to differentiate from framed & unframed
	HeaderMagic         uint32 = 0x0FFF0000
	HeaderMask          uint32 = 0xFFFF0000
	FlagsMask           uint32 = 0x0000FFFF
	HTTPServerMagic     uint32 = 0x504F5354 // POST
	HTTPClientMagic     uint32 = 0x48545450 // HTTP
	HTTPGetClientMagic  uint32 = 0x47455420 // GET
	HTTPHeadClientMagic uint32 = 0x48454144 // HEAD
	BigFrameMagic       uint32 = 0x42494746 // BIGF
	MaxFrameSize        uint32 = 0x3FFFFFFF
	CommonHeaderSize    uint64 = 10
	MaxHeaderSize       uint32 = 131071
)

Header keys

View Source
const (
	DefaulprotoID     = ProtocolIDCompact
	DefaultClientType = HeaderClientType
)
View Source
const (
	VERSION_MASK = 0xffff0000
	VERSION_1    = 0x80010000
)
View Source
const (
	UNKNOWN_PROTOCOL_EXCEPTION = 0
	INVALID_DATA               = 1
	NEGATIVE_SIZE              = 2
	SIZE_LIMIT                 = 3
	BAD_VERSION                = 4
	NOT_IMPLEMENTED            = 5
	DEPTH_LIMIT                = 6
)
View Source
const (
	UNKNOWN_TRANSPORT_EXCEPTION = 0
	NOT_OPEN                    = 1
	ALREADY_OPEN                = 2
	TIMED_OUT                   = 3
	END_OF_FILE                 = 4
	INTERRUPTED                 = 5
	BAD_ARGS                    = 6
	CORRUPTED_DATA              = 7
	NOT_SUPPORTED               = 9
	INVALID_STATE               = 10
	INVALID_FRAME_SIZE          = 11
	SSL_ERROR                   = 12
	COULD_NOT_BIND              = 13
	NETWORK_ERROR               = 15
)
View Source
const (
	STOP   = 0
	VOID   = 1
	BOOL   = 2
	BYTE   = 3
	I08    = 3
	DOUBLE = 4
	I16    = 6
	I32    = 8
	I64    = 10
	STRING = 11
	UTF7   = 11
	STRUCT = 12
	MAP    = 13
	SET    = 14
	LIST   = 15
	UTF8   = 16
	UTF16  = 17
	BINARY = 18
	FLOAT  = 19
)
View Source
const BinaryVersion1 uint32 = 0x80010000
View Source
const BinaryVersionMask uint32 = 0xffff0000
View Source
const DEFAULT_MAX_LENGTH = 16384000
View Source
const DEFAULT_RECURSION_DEPTH = 64

The maximum recursive depth the skip() function will traverse

View Source
const MULTIPLEXED_SEPARATOR = ":"
View Source
const (
	THRIFT_JSON_PROTOCOL_VERSION = 1
)
View Source
const UnknownRemaining = ^uint64(0)

UnknownRemaining is used by transports that can not return a real answer for RemainingBytes()

Variables

View Source
var (
	JSON_COMMA                   []byte
	JSON_COLON                   []byte
	JSON_LBRACE                  []byte
	JSON_RBRACE                  []byte
	JSON_LBRACKET                []byte
	JSON_RBRACKET                []byte
	JSON_QUOTE                   byte
	JSON_QUOTE_BYTES             []byte
	JSON_NULL                    []byte
	JSON_TRUE                    []byte
	JSON_FALSE                   []byte
	JSON_INFINITY                string
	JSON_NEGATIVE_INFINITY       string
	JSON_NAN                     string
	JSON_INFINITY_BYTES          []byte
	JSON_NEGATIVE_INFINITY_BYTES []byte
	JSON_NAN_BYTES               []byte
)
View Source
var ANONYMOUS_FIELD *field
View Source
var DefaultHTTPClient *http.Client = http.DefaultClient

Default to using the shared http client. Library users are free to change this global client or specify one through HTTPClientOptions.

View Source
var ErrServerClosed = errors.New("thrift: Server closed")

ErrServerClosed is returned by the Serve methods after a call to Stop

Functions

func BoolPtr

func BoolPtr(v bool) *bool

func ByteSlicePtr

func ByteSlicePtr(v []byte) *[]byte

func Float32Ptr

func Float32Ptr(v float32) *float32

func Float64Ptr

func Float64Ptr(v float64) *float64

func HeadersFromContext

func HeadersFromContext(ctx context.Context) map[string]string

HeadersFromContext extracts headers for this message, both per-message and persistent headers. When both a per-message header and a persistent header exist with the same name, the persistent header is returned. This is also the behaviour of the C++ implementation. This function returns nil when the underlying transport/protocol do not support headers.

func InputProtocolFactory

func InputProtocolFactory(factory ProtocolFactory) func(*ServerOptions)

InputProtocolFactory sets the input protocol factory

func InputTransportFactory

func InputTransportFactory(factory TransportFactory) func(*ServerOptions)

InputTransportFactory sets the input transport factory

func Int16Ptr

func Int16Ptr(v int16) *int16

func Int32Ptr

func Int32Ptr(v int32) *int32

func Int64Ptr

func Int64Ptr(v int64) *int64

func IntPtr

func IntPtr(v int) *int

func Logger

func Logger(log *log.Logger) func(*ServerOptions)

Logger sets the logger used for the server

func NewStoredMessageProtocol

func NewStoredMessageProtocol(protocol Protocol, name string, typeId MessageType, seqid int32) *storedMessageProtocol

func NewThriftHandlerContextFunc

func NewThriftHandlerContextFunc(processor ProcessorContext,
	inPfactory, outPfactory ProtocolFactory) func(w http.ResponseWriter, r *http.Request)

NewThriftHandlerContextFunc is a function that create a ready to use Apache Thrift Handler function

func NewThriftHandlerFunc

func NewThriftHandlerFunc(processor Processor,
	inPfactory, outPfactory ProtocolFactory) func(w http.ResponseWriter, r *http.Request)

NewThriftHandlerFunc is a function that create a ready to use Apache Thrift Handler function

func OutputProtocolFactory

func OutputProtocolFactory(factory ProtocolFactory) func(*ServerOptions)

OutputProtocolFactory sets the output protocol factory

func OutputTransportFactory

func OutputTransportFactory(factory TransportFactory) func(*ServerOptions)

OutputTransportFactory sets the output transport factory

func PrependError

func PrependError(prepend string, err error) error

PrependError prepends additional information to an error without losing the thrift exception interface

func ProtocolFactories

func ProtocolFactories(factory ProtocolFactory) func(*ServerOptions)

ProtocolFactories sets both input and output protocol factories

func Skip

func Skip(self Protocol, fieldType Type, maxDepth int) (err error)

Skips over the next data element from the provided input Protocol object.

func SkipDefaultDepth

func SkipDefaultDepth(prot Protocol, typeId Type) (err error)

Skips over the next data element from the provided input Protocol object.

func StringPtr

func StringPtr(v string) *string

func TransportFactories

func TransportFactories(factory TransportFactory) func(*ServerOptions)

TransportFactories sets both input and output transport factories

func Uint32Ptr

func Uint32Ptr(v uint32) *uint32

func Uint64Ptr

func Uint64Ptr(v uint64) *uint64

func WithConnInfo

func WithConnInfo(ctx context.Context, client Transport) context.Context

WithConnInfo adds connection info (from a thrift.Transport) to context, if applicable

func WithInterceptor

func WithInterceptor(interceptor Interceptor) func(*ServerOptions)

WithInterceptor sets the interceptor for the server

func WithProtocol

func WithProtocol(ctx context.Context, proto Protocol) context.Context

WithProtocol attaches thrift protocol to a context

func WithRPCOptions

func WithRPCOptions(ctx context.Context, opts *RPCOptions) context.Context

WithRPCOptions sets the RPCOptions in a client request go context

func WithRequestContext

func WithRequestContext(ctx context.Context, reqCtx *RequestContext) context.Context

WithRequestContext sets the RequestContext in a given go context

Types

type ApplicationException

type ApplicationException interface {
	Exception
	TypeID() int32
	Read(iprot Protocol) (ApplicationException, error)
	Write(oprot Protocol) error
}

ApplicationException is an application level Thrift exception

func NewApplicationException

func NewApplicationException(exceptionType int32, message string) ApplicationException

NewApplicationException creates a new ApplicationException

func NewApplicationExceptionCause

func NewApplicationExceptionCause(exceptionType int32, message string, cause error) ApplicationException

NewApplicationExceptionCause creates a new ApplicationException with a root cause error

type BinaryProtocol

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

func NewBinaryProtocol

func NewBinaryProtocol(t Transport, strictRead, strictWrite bool) *BinaryProtocol

func NewBinaryProtocolTransport

func NewBinaryProtocolTransport(t Transport) *BinaryProtocol

func (*BinaryProtocol) Flush

func (p *BinaryProtocol) Flush() (err error)

func (*BinaryProtocol) ReadBinary

func (p *BinaryProtocol) ReadBinary() ([]byte, error)

func (*BinaryProtocol) ReadBool

func (p *BinaryProtocol) ReadBool() (bool, error)

func (*BinaryProtocol) ReadByte

func (p *BinaryProtocol) ReadByte() (byte, error)

func (*BinaryProtocol) ReadDouble

func (p *BinaryProtocol) ReadDouble() (value float64, err error)

func (*BinaryProtocol) ReadFieldBegin

func (p *BinaryProtocol) ReadFieldBegin() (name string, typeId Type, seqId int16, err error)

func (*BinaryProtocol) ReadFieldEnd

func (p *BinaryProtocol) ReadFieldEnd() error

func (*BinaryProtocol) ReadFloat

func (p *BinaryProtocol) ReadFloat() (value float32, err error)

func (*BinaryProtocol) ReadI16

func (p *BinaryProtocol) ReadI16() (value int16, err error)

func (*BinaryProtocol) ReadI32

func (p *BinaryProtocol) ReadI32() (value int32, err error)

func (*BinaryProtocol) ReadI64

func (p *BinaryProtocol) ReadI64() (value int64, err error)

func (*BinaryProtocol) ReadListBegin

func (p *BinaryProtocol) ReadListBegin() (elemType Type, size int, err error)

func (*BinaryProtocol) ReadListEnd

func (p *BinaryProtocol) ReadListEnd() error

func (*BinaryProtocol) ReadMapBegin

func (p *BinaryProtocol) ReadMapBegin() (kType, vType Type, size int, err error)

func (*BinaryProtocol) ReadMapEnd

func (p *BinaryProtocol) ReadMapEnd() error

func (*BinaryProtocol) ReadMessageBegin

func (p *BinaryProtocol) ReadMessageBegin() (name string, typeId MessageType, seqId int32, err error)

func (*BinaryProtocol) ReadMessageEnd

func (p *BinaryProtocol) ReadMessageEnd() error

func (*BinaryProtocol) ReadSetBegin

func (p *BinaryProtocol) ReadSetBegin() (elemType Type, size int, err error)

func (*BinaryProtocol) ReadSetEnd

func (p *BinaryProtocol) ReadSetEnd() error

func (*BinaryProtocol) ReadString

func (p *BinaryProtocol) ReadString() (value string, err error)

func (*BinaryProtocol) ReadStructBegin

func (p *BinaryProtocol) ReadStructBegin() (name string, err error)

func (*BinaryProtocol) ReadStructEnd

func (p *BinaryProtocol) ReadStructEnd() error

func (*BinaryProtocol) Skip

func (p *BinaryProtocol) Skip(fieldType Type) (err error)

func (*BinaryProtocol) Transport

func (p *BinaryProtocol) Transport() Transport

func (*BinaryProtocol) WriteBinary

func (p *BinaryProtocol) WriteBinary(value []byte) error

func (*BinaryProtocol) WriteBool

func (p *BinaryProtocol) WriteBool(value bool) error

func (*BinaryProtocol) WriteByte

func (p *BinaryProtocol) WriteByte(value byte) error

func (*BinaryProtocol) WriteDouble

func (p *BinaryProtocol) WriteDouble(value float64) error

func (*BinaryProtocol) WriteFieldBegin

func (p *BinaryProtocol) WriteFieldBegin(name string, typeId Type, id int16) error

func (*BinaryProtocol) WriteFieldEnd

func (p *BinaryProtocol) WriteFieldEnd() error

func (*BinaryProtocol) WriteFieldStop

func (p *BinaryProtocol) WriteFieldStop() error

func (*BinaryProtocol) WriteFloat

func (p *BinaryProtocol) WriteFloat(value float32) error

func (*BinaryProtocol) WriteI16

func (p *BinaryProtocol) WriteI16(value int16) error

func (*BinaryProtocol) WriteI32

func (p *BinaryProtocol) WriteI32(value int32) error

func (*BinaryProtocol) WriteI64

func (p *BinaryProtocol) WriteI64(value int64) error

func (*BinaryProtocol) WriteListBegin

func (p *BinaryProtocol) WriteListBegin(elemType Type, size int) error

func (*BinaryProtocol) WriteListEnd

func (p *BinaryProtocol) WriteListEnd() error

func (*BinaryProtocol) WriteMapBegin

func (p *BinaryProtocol) WriteMapBegin(keyType Type, valueType Type, size int) error

func (*BinaryProtocol) WriteMapEnd

func (p *BinaryProtocol) WriteMapEnd() error

func (*BinaryProtocol) WriteMessageBegin

func (p *BinaryProtocol) WriteMessageBegin(name string, typeId MessageType, seqId int32) error

func (*BinaryProtocol) WriteMessageEnd

func (p *BinaryProtocol) WriteMessageEnd() error

func (*BinaryProtocol) WriteSetBegin

func (p *BinaryProtocol) WriteSetBegin(elemType Type, size int) error

func (*BinaryProtocol) WriteSetEnd

func (p *BinaryProtocol) WriteSetEnd() error

func (*BinaryProtocol) WriteString

func (p *BinaryProtocol) WriteString(value string) error

func (*BinaryProtocol) WriteStructBegin

func (p *BinaryProtocol) WriteStructBegin(name string) error

func (*BinaryProtocol) WriteStructEnd

func (p *BinaryProtocol) WriteStructEnd() error

type BinaryProtocolFactory

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

func NewBinaryProtocolFactory

func NewBinaryProtocolFactory(strictRead, strictWrite bool) *BinaryProtocolFactory

func NewBinaryProtocolFactoryDefault

func NewBinaryProtocolFactoryDefault() *BinaryProtocolFactory

func (*BinaryProtocolFactory) GetProtocol

func (p *BinaryProtocolFactory) GetProtocol(t Transport) Protocol

type BufferedTransport

type BufferedTransport struct {
	bufio.ReadWriter
	// contains filtered or unexported fields
}

func NewBufferedTransport

func NewBufferedTransport(trans Transport, bufferSize int) *BufferedTransport

func (*BufferedTransport) Close

func (p *BufferedTransport) Close() (err error)

func (*BufferedTransport) Flush

func (p *BufferedTransport) Flush() error

func (*BufferedTransport) IsOpen

func (p *BufferedTransport) IsOpen() bool

func (*BufferedTransport) Open

func (p *BufferedTransport) Open() (err error)

func (*BufferedTransport) Read

func (p *BufferedTransport) Read(b []byte) (int, error)

func (*BufferedTransport) RemainingBytes

func (p *BufferedTransport) RemainingBytes() (num_bytes uint64)

func (*BufferedTransport) Write

func (p *BufferedTransport) Write(b []byte) (int, error)

type BufferedTransportFactory

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

func NewBufferedTransportFactory

func NewBufferedTransportFactory(bufferSize int) *BufferedTransportFactory

func (*BufferedTransportFactory) GetTransport

func (p *BufferedTransportFactory) GetTransport(trans Transport) Transport

type ClientConn

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

ClientConn holds all the connection information for a thrift client

func NewClientConn

func NewClientConn(t Transport, pf ProtocolFactory) ClientConn

NewClientConn creates a new ClientConn object using the provided ProtocolFactory

func NewClientConnWithProtocols

func NewClientConnWithProtocols(t Transport, iproto, oproto Protocol) ClientConn

NewClientConnWithProtocols creates a new ClientConn object using the input and output protocols provided

func (*ClientConn) Close

func (cc *ClientConn) Close() error

Close closes the client connection

func (*ClientConn) IsOpen

func (cc *ClientConn) IsOpen() bool

IsOpen return true if the client connection is open; otherwise, it returns false.

func (*ClientConn) Open

func (cc *ClientConn) Open() error

Open opens the client connection

func (*ClientConn) RecvMsg

func (cc *ClientConn) RecvMsg(method string, res IResponse) error

RecvMsg receives the response from a call to a thrift endpoint

func (*ClientConn) SendMsg

func (cc *ClientConn) SendMsg(method string, req IRequest, msgType MessageType) error

SendMsg sends a request to a given thrift endpoint

func (*ClientConn) Transport

func (cc *ClientConn) Transport() Transport

Transport returns the underlying Transport object inside the ClientConn object

type ClientInterface

type ClientInterface interface {
	Open() error
	Close() error
	IsOpen() bool
}

ClientInterface specifies the common methods every thrift client should implement

type ClientType

type ClientType int64
const (
	HeaderClientType ClientType = iota
	FramedDeprecated
	UnframedDeprecated
	HTTPServerType
	HTTPClientType
	FramedCompact
	HTTPGetClientType
	UnknownClientType
	UnframedCompactDeprecated
)

func (ClientType) String

func (c ClientType) String() string

type CompactProtocol

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

func NewCompactProtocol

func NewCompactProtocol(trans Transport) *CompactProtocol

Create a CompactProtocol given a Transport

func (*CompactProtocol) Flush

func (p *CompactProtocol) Flush() (err error)

func (*CompactProtocol) ReadBinary

func (p *CompactProtocol) ReadBinary() (value []byte, err error)

Read a []byte from the wire.

func (*CompactProtocol) ReadBool

func (p *CompactProtocol) ReadBool() (value bool, err error)

Read a boolean off the wire. If this is a boolean field, the value should already have been read during readFieldBegin, so we'll just consume the pre-stored value. Otherwise, read a byte.

func (*CompactProtocol) ReadByte

func (p *CompactProtocol) ReadByte() (byte, error)

Read a single byte off the wire. Nothing interesting here.

func (*CompactProtocol) ReadDouble

func (p *CompactProtocol) ReadDouble() (value float64, err error)

No magic here - just read a double off the wire.

func (*CompactProtocol) ReadFieldBegin

func (p *CompactProtocol) ReadFieldBegin() (name string, typeId Type, id int16, err error)

Read a field header off the wire.

func (*CompactProtocol) ReadFieldEnd

func (p *CompactProtocol) ReadFieldEnd() error

func (*CompactProtocol) ReadFloat

func (p *CompactProtocol) ReadFloat() (value float32, err error)

No magic here - just read a float off the wire.

func (*CompactProtocol) ReadI16

func (p *CompactProtocol) ReadI16() (value int16, err error)

Read an i16 from the wire as a zigzag varint.

func (*CompactProtocol) ReadI32

func (p *CompactProtocol) ReadI32() (value int32, err error)

Read an i32 from the wire as a zigzag varint.

func (*CompactProtocol) ReadI64

func (p *CompactProtocol) ReadI64() (value int64, err error)

Read an i64 from the wire as a zigzag varint.

func (*CompactProtocol) ReadListBegin

func (p *CompactProtocol) ReadListBegin() (elemType Type, size int, err error)

Read a list header off the wire. If the list size is 0-14, the size will be packed into the element type header. If it's a longer list, the 4 MSB of the element type header will be 0xF, and a varint will follow with the true size.

func (*CompactProtocol) ReadListEnd

func (p *CompactProtocol) ReadListEnd() error

func (*CompactProtocol) ReadMapBegin

func (p *CompactProtocol) ReadMapBegin() (keyType Type, valueType Type, size int, err error)

Read a map header off the wire. If the size is zero, skip reading the key and value type. This means that 0-length maps will yield Maps without the "correct" types.

func (*CompactProtocol) ReadMapEnd

func (p *CompactProtocol) ReadMapEnd() error

func (*CompactProtocol) ReadMessageBegin

func (p *CompactProtocol) ReadMessageBegin() (name string, typeId MessageType, seqId int32, err error)

Read a message header.

func (*CompactProtocol) ReadMessageEnd

func (p *CompactProtocol) ReadMessageEnd() error

func (*CompactProtocol) ReadSetBegin

func (p *CompactProtocol) ReadSetBegin() (elemType Type, size int, err error)

Read a set header off the wire. If the set size is 0-14, the size will be packed into the element type header. If it's a longer set, the 4 MSB of the element type header will be 0xF, and a varint will follow with the true size.

func (*CompactProtocol) ReadSetEnd

func (p *CompactProtocol) ReadSetEnd() error

func (*CompactProtocol) ReadString

func (p *CompactProtocol) ReadString() (value string, err error)

Reads a []byte (via readBinary), and then UTF-8 decodes it.

func (*CompactProtocol) ReadStructBegin

func (p *CompactProtocol) ReadStructBegin() (name string, err error)

Read a struct begin. There's nothing on the wire for this, but it is our opportunity to push a new struct begin marker onto the field stack.

func (*CompactProtocol) ReadStructEnd

func (p *CompactProtocol) ReadStructEnd() error

Doesn't actually consume any wire data, just removes the last field for this struct from the field stack.

func (*CompactProtocol) Skip

func (p *CompactProtocol) Skip(fieldType Type) (err error)

func (*CompactProtocol) Transport

func (p *CompactProtocol) Transport() Transport

func (*CompactProtocol) WriteBinary

func (p *CompactProtocol) WriteBinary(bin []byte) error

Write a byte array, using a varint for the size.

func (*CompactProtocol) WriteBool

func (p *CompactProtocol) WriteBool(value bool) error

func (*CompactProtocol) WriteByte

func (p *CompactProtocol) WriteByte(value byte) error

Write a byte. Nothing to see here!

func (*CompactProtocol) WriteDouble

func (p *CompactProtocol) WriteDouble(value float64) error

Write a double to the wire as 8 bytes.

func (*CompactProtocol) WriteFieldBegin

func (p *CompactProtocol) WriteFieldBegin(name string, typeId Type, id int16) error

func (*CompactProtocol) WriteFieldEnd

func (p *CompactProtocol) WriteFieldEnd() error

func (*CompactProtocol) WriteFieldStop

func (p *CompactProtocol) WriteFieldStop() error

func (*CompactProtocol) WriteFloat

func (p *CompactProtocol) WriteFloat(value float32) error

Write a float to the wire as 4 bytes.

func (*CompactProtocol) WriteI16

func (p *CompactProtocol) WriteI16(value int16) error

Write an I16 as a zigzag varint.

func (*CompactProtocol) WriteI32

func (p *CompactProtocol) WriteI32(value int32) error

Write an i32 as a zigzag varint.

func (*CompactProtocol) WriteI64

func (p *CompactProtocol) WriteI64(value int64) error

Write an i64 as a zigzag varint.

func (*CompactProtocol) WriteListBegin

func (p *CompactProtocol) WriteListBegin(elemType Type, size int) error

Write a list header.

func (*CompactProtocol) WriteListEnd

func (p *CompactProtocol) WriteListEnd() error

func (*CompactProtocol) WriteMapBegin

func (p *CompactProtocol) WriteMapBegin(keyType Type, valueType Type, size int) error

func (*CompactProtocol) WriteMapEnd

func (p *CompactProtocol) WriteMapEnd() error

func (*CompactProtocol) WriteMessageBegin

func (p *CompactProtocol) WriteMessageBegin(name string, typeId MessageType, seqid int32) error

Write a message header to the wire. Compact Protocol messages contain the protocol version so we can migrate forwards in the future if need be.

func (*CompactProtocol) WriteMessageEnd

func (p *CompactProtocol) WriteMessageEnd() error

func (*CompactProtocol) WriteSetBegin

func (p *CompactProtocol) WriteSetBegin(elemType Type, size int) error

Write a set header.

func (*CompactProtocol) WriteSetEnd

func (p *CompactProtocol) WriteSetEnd() error

func (*CompactProtocol) WriteString

func (p *CompactProtocol) WriteString(value string) error

Write a string to the wire with a varint size preceding.

func (*CompactProtocol) WriteStructBegin

func (p *CompactProtocol) WriteStructBegin(name string) error

Write a struct begin. This doesn't actually put anything on the wire. We use it as an opportunity to put special placeholder markers on the field stack so we can get the field id deltas correct.

func (*CompactProtocol) WriteStructEnd

func (p *CompactProtocol) WriteStructEnd() error

Write a struct end. This doesn't actually put anything on the wire. We use this as an opportunity to pop the last field from the current struct off of the field stack.

type CompactProtocolFactory

type CompactProtocolFactory struct{}

func NewCompactProtocolFactory

func NewCompactProtocolFactory() *CompactProtocolFactory

func (*CompactProtocolFactory) GetProtocol

func (p *CompactProtocolFactory) GetProtocol(trans Transport) Protocol

type ConcurrentServer

type ConcurrentServer struct {
	*SimpleServer
}

ConcurrentServer is the concurrent counterpart of SimpleServer It is able to process out-of-order requests on the same transport

func NewConcurrentServer

func NewConcurrentServer(processor Processor, serverTransport ServerTransport, options ...func(*ServerOptions)) *ConcurrentServer

NewConcurrentServer create a new NewConcurrentServer

func NewConcurrentServerContext

func NewConcurrentServerContext(processor ProcessorContext, serverTransport ServerTransport, options ...func(*ServerOptions)) *ConcurrentServer

NewConcurrentServerContext is a version of the ConcurrentServer that supports contexts.

func NewConcurrentServerFactory

func NewConcurrentServerFactory(processorFactory ProcessorFactory, serverTransport ServerTransport, options ...func(*ServerOptions)) *ConcurrentServer

NewConcurrentServerFactory create a new server factory

func NewConcurrentServerFactoryContext

func NewConcurrentServerFactoryContext(processorFactory ProcessorFactoryContext, serverTransport ServerTransport, options ...func(*ServerOptions)) *ConcurrentServer

NewConcurrentServerFactoryContext is a version of the ConcurrentServerFactory that supports contexts.

type ConnInfo

type ConnInfo struct {
	LocalAddr  net.Addr
	RemoteAddr net.Addr
	// contains filtered or unexported fields
}

ConnInfo contains connection information from clients of the SimpleServer.

func ConnInfoFromContext

func ConnInfoFromContext(ctx context.Context) (ConnInfo, bool)

ConnInfoFromContext extracts and returns ConnInfo from context.

func (ConnInfo) String

func (c ConnInfo) String() string

String implements the fmt.Stringer interface.

func (ConnInfo) TLS

func (c ConnInfo) TLS() *tls.ConnectionState

TLS returns the TLS connection state.

type DebugProtocol

type DebugProtocol struct {
	Delegate  Protocol
	LogPrefix string
}

func (*DebugProtocol) Flush

func (tdp *DebugProtocol) Flush() (err error)

func (*DebugProtocol) ReadBinary

func (tdp *DebugProtocol) ReadBinary() (value []byte, err error)

func (*DebugProtocol) ReadBool

func (tdp *DebugProtocol) ReadBool() (value bool, err error)

func (*DebugProtocol) ReadByte

func (tdp *DebugProtocol) ReadByte() (value byte, err error)

func (*DebugProtocol) ReadDouble

func (tdp *DebugProtocol) ReadDouble() (value float64, err error)

func (*DebugProtocol) ReadFieldBegin

func (tdp *DebugProtocol) ReadFieldBegin() (name string, typeId Type, id int16, err error)

func (*DebugProtocol) ReadFieldEnd

func (tdp *DebugProtocol) ReadFieldEnd() (err error)

func (*DebugProtocol) ReadFloat

func (tdp *DebugProtocol) ReadFloat() (value float32, err error)

func (*DebugProtocol) ReadI16

func (tdp *DebugProtocol) ReadI16() (value int16, err error)

func (*DebugProtocol) ReadI32

func (tdp *DebugProtocol) ReadI32() (value int32, err error)

func (*DebugProtocol) ReadI64

func (tdp *DebugProtocol) ReadI64() (value int64, err error)

func (*DebugProtocol) ReadListBegin

func (tdp *DebugProtocol) ReadListBegin() (elemType Type, size int, err error)

func (*DebugProtocol) ReadListEnd

func (tdp *DebugProtocol) ReadListEnd() (err error)

func (*DebugProtocol) ReadMapBegin

func (tdp *DebugProtocol) ReadMapBegin() (keyType Type, valueType Type, size int, err error)

func (*DebugProtocol) ReadMapEnd

func (tdp *DebugProtocol) ReadMapEnd() (err error)

func (*DebugProtocol) ReadMessageBegin

func (tdp *DebugProtocol) ReadMessageBegin() (name string, typeId MessageType, seqid int32, err error)

func (*DebugProtocol) ReadMessageEnd

func (tdp *DebugProtocol) ReadMessageEnd() (err error)

func (*DebugProtocol) ReadSetBegin

func (tdp *DebugProtocol) ReadSetBegin() (elemType Type, size int, err error)

func (*DebugProtocol) ReadSetEnd

func (tdp *DebugProtocol) ReadSetEnd() (err error)

func (*DebugProtocol) ReadString

func (tdp *DebugProtocol) ReadString() (value string, err error)

func (*DebugProtocol) ReadStructBegin

func (tdp *DebugProtocol) ReadStructBegin() (name string, err error)

func (*DebugProtocol) ReadStructEnd

func (tdp *DebugProtocol) ReadStructEnd() (err error)

func (*DebugProtocol) Skip

func (tdp *DebugProtocol) Skip(fieldType Type) (err error)

func (*DebugProtocol) Transport

func (tdp *DebugProtocol) Transport() Transport

func (*DebugProtocol) WriteBinary

func (tdp *DebugProtocol) WriteBinary(value []byte) error

func (*DebugProtocol) WriteBool

func (tdp *DebugProtocol) WriteBool(value bool) error

func (*DebugProtocol) WriteByte

func (tdp *DebugProtocol) WriteByte(value byte) error

func (*DebugProtocol) WriteDouble

func (tdp *DebugProtocol) WriteDouble(value float64) error

func (*DebugProtocol) WriteFieldBegin

func (tdp *DebugProtocol) WriteFieldBegin(name string, typeId Type, id int16) error

func (*DebugProtocol) WriteFieldEnd

func (tdp *DebugProtocol) WriteFieldEnd() error

func (*DebugProtocol) WriteFieldStop

func (tdp *DebugProtocol) WriteFieldStop() error

func (*DebugProtocol) WriteFloat

func (tdp *DebugProtocol) WriteFloat(value float32) error

func (*DebugProtocol) WriteI16

func (tdp *DebugProtocol) WriteI16(value int16) error

func (*DebugProtocol) WriteI32

func (tdp *DebugProtocol) WriteI32(value int32) error

func (*DebugProtocol) WriteI64

func (tdp *DebugProtocol) WriteI64(value int64) error

func (*DebugProtocol) WriteListBegin

func (tdp *DebugProtocol) WriteListBegin(elemType Type, size int) error

func (*DebugProtocol) WriteListEnd

func (tdp *DebugProtocol) WriteListEnd() error

func (*DebugProtocol) WriteMapBegin

func (tdp *DebugProtocol) WriteMapBegin(keyType Type, valueType Type, size int) error

func (*DebugProtocol) WriteMapEnd

func (tdp *DebugProtocol) WriteMapEnd() error

func (*DebugProtocol) WriteMessageBegin

func (tdp *DebugProtocol) WriteMessageBegin(name string, typeId MessageType, seqid int32) error

func (*DebugProtocol) WriteMessageEnd

func (tdp *DebugProtocol) WriteMessageEnd() error

func (*DebugProtocol) WriteSetBegin

func (tdp *DebugProtocol) WriteSetBegin(elemType Type, size int) error

func (*DebugProtocol) WriteSetEnd

func (tdp *DebugProtocol) WriteSetEnd() error

func (*DebugProtocol) WriteString

func (tdp *DebugProtocol) WriteString(value string) error

func (*DebugProtocol) WriteStructBegin

func (tdp *DebugProtocol) WriteStructBegin(name string) error

func (*DebugProtocol) WriteStructEnd

func (tdp *DebugProtocol) WriteStructEnd() error

type DebugProtocolFactory

type DebugProtocolFactory struct {
	Underlying ProtocolFactory
	LogPrefix  string
}

func NewDebugProtocolFactory

func NewDebugProtocolFactory(underlying ProtocolFactory, logPrefix string) *DebugProtocolFactory

func (*DebugProtocolFactory) GetProtocol

func (t *DebugProtocolFactory) GetProtocol(trans Transport) Protocol

type Deserializer

type Deserializer struct {
	Transport Transport
	Protocol  Protocol
}

func NewCompactDeserializer

func NewCompactDeserializer() *Deserializer

NewCompactDeserializer creates a new deserializer using the compact protocol

func NewDeserializer

func NewDeserializer() *Deserializer

func (*Deserializer) Read

func (t *Deserializer) Read(msg Struct, b []byte) (err error)

func (*Deserializer) ReadString

func (t *Deserializer) ReadString(msg Struct, s string) (err error)

type Exception

type Exception interface {
	error
}

Exception is a generic thrift exception

func Process

func Process(processor Processor, iprot, oprot Protocol) (keepOpen bool, exc Exception)

Process is a utility function to take a processor and an input and output protocol, and fully process a message. It understands the thrift protocol. A framework could be written outside of the thrift library but would need to duplicate this logic.

func ProcessContext

func ProcessContext(ctx context.Context, processor ProcessorContext, iprot, oprot Protocol) (keepOpen bool, ext Exception)

ProcessContext is a Process that supports contexts.

type Flusher

type Flusher interface {
	Flush() (err error)
}

Flusher is the interface that wraps the basic Flush method

type FramedTransport

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

func NewFramedTransport

func NewFramedTransport(transport Transport) *FramedTransport

func NewFramedTransportMaxLength

func NewFramedTransportMaxLength(transport Transport, maxLength uint32) *FramedTransport

func (*FramedTransport) Close

func (p *FramedTransport) Close() error

func (*FramedTransport) Flush

func (p *FramedTransport) Flush() error

func (*FramedTransport) IsOpen

func (p *FramedTransport) IsOpen() bool

func (*FramedTransport) Open

func (p *FramedTransport) Open() error

func (*FramedTransport) Read

func (p *FramedTransport) Read(buf []byte) (l int, err error)

func (*FramedTransport) ReadByte

func (p *FramedTransport) ReadByte() (c byte, err error)

func (*FramedTransport) RemainingBytes

func (p *FramedTransport) RemainingBytes() (num_bytes uint64)

func (*FramedTransport) Write

func (p *FramedTransport) Write(buf []byte) (int, error)

func (*FramedTransport) WriteByte

func (p *FramedTransport) WriteByte(c byte) error

func (*FramedTransport) WriteString

func (p *FramedTransport) WriteString(s string) (n int, err error)

type HTTPClient

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

func (*HTTPClient) Close

func (p *HTTPClient) Close() error

func (*HTTPClient) DelHeader

func (p *HTTPClient) DelHeader(key string)

Deletes the HTTP Header given a Header Key for this specific Thrift Transport It is important that you first assert the Transport as a HTTPClient type like so:

httpTrans := trans.(HTTPClient) httpTrans.DelHeader("User-Agent")

func (*HTTPClient) Flush

func (p *HTTPClient) Flush() error

func (*HTTPClient) GetHeader

func (p *HTTPClient) GetHeader(key string) string

Get the HTTP Header represented by the supplied Header Key for this specific Thrift Transport It is important that you first assert the Transport as a HTTPClient type like so:

httpTrans := trans.(HTTPClient) hdrValue := httpTrans.GetHeader("User-Agent")

func (*HTTPClient) IsOpen

func (p *HTTPClient) IsOpen() bool

func (*HTTPClient) Open

func (p *HTTPClient) Open() error

func (*HTTPClient) Read

func (p *HTTPClient) Read(buf []byte) (int, error)

func (*HTTPClient) ReadByte

func (p *HTTPClient) ReadByte() (c byte, err error)

func (*HTTPClient) RemainingBytes

func (p *HTTPClient) RemainingBytes() (num_bytes uint64)

func (*HTTPClient) SetHeader

func (p *HTTPClient) SetHeader(key string, value string)

Set the HTTP Header for this specific Thrift Transport It is important that you first assert the Transport as a HTTPClient type like so:

httpTrans := trans.(HTTPClient) httpTrans.SetHeader("User-Agent","Thrift Client 1.0")

func (*HTTPClient) Write

func (p *HTTPClient) Write(buf []byte) (int, error)

func (*HTTPClient) WriteByte

func (p *HTTPClient) WriteByte(c byte) error

func (*HTTPClient) WriteString

func (p *HTTPClient) WriteString(s string) (n int, err error)

type HTTPClientOptions

type HTTPClientOptions struct {
	// If nil, DefaultHTTPClient is used
	Client *http.Client
}

type HTTPClientTransportFactory

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

func NewHTTPClientTransportFactory

func NewHTTPClientTransportFactory(url string) *HTTPClientTransportFactory

func NewHTTPClientTransportFactoryWithOptions

func NewHTTPClientTransportFactoryWithOptions(url string, options HTTPClientOptions) *HTTPClientTransportFactory

func NewHTTPPostClientTransportFactory

func NewHTTPPostClientTransportFactory(url string) *HTTPClientTransportFactory

func NewHTTPPostClientTransportFactoryWithOptions

func NewHTTPPostClientTransportFactoryWithOptions(url string, options HTTPClientOptions) *HTTPClientTransportFactory

func (*HTTPClientTransportFactory) GetTransport

func (p *HTTPClientTransportFactory) GetTransport(trans Transport) Transport

type HeaderFlags

type HeaderFlags uint16
const (
	HeaderFlagSupportOutOfOrder HeaderFlags = 0x01
	HeaderFlagDuplexReverse     HeaderFlags = 0x08
)

type HeaderProtocol

type HeaderProtocol struct {
	Protocol
	// contains filtered or unexported fields
}

func NewHeaderProtocol

func NewHeaderProtocol(trans Transport) *HeaderProtocol

func (*HeaderProtocol) AddTransform

func (p *HeaderProtocol) AddTransform(trans TransformID) error

func (*HeaderProtocol) ClearHeaders

func (p *HeaderProtocol) ClearHeaders()

func (*HeaderProtocol) ClearPersistentHeaders

func (p *HeaderProtocol) ClearPersistentHeaders()

func (*HeaderProtocol) Flush

func (p *HeaderProtocol) Flush() (err error)

func (*HeaderProtocol) Header

func (p *HeaderProtocol) Header(key string) (string, bool)

func (*HeaderProtocol) HeaderTransport

func (p *HeaderProtocol) HeaderTransport() Transport

func (*HeaderProtocol) Headers

func (p *HeaderProtocol) Headers() map[string]string

func (*HeaderProtocol) Identity

func (p *HeaderProtocol) Identity() string

func (*HeaderProtocol) PeerIdentity

func (p *HeaderProtocol) PeerIdentity() string

func (*HeaderProtocol) PersistentHeader

func (p *HeaderProtocol) PersistentHeader(key string) (string, bool)

func (*HeaderProtocol) PersistentHeaders

func (p *HeaderProtocol) PersistentHeaders() map[string]string

func (*HeaderProtocol) ProtocolID

func (p *HeaderProtocol) ProtocolID() ProtocolID

func (*HeaderProtocol) ReadHeader

func (p *HeaderProtocol) ReadHeader(key string) (string, bool)

func (*HeaderProtocol) ReadHeaders

func (p *HeaderProtocol) ReadHeaders() map[string]string

func (*HeaderProtocol) ReadMessageBegin

func (p *HeaderProtocol) ReadMessageBegin() (name string, typeId MessageType, seqid int32, err error)

func (*HeaderProtocol) ResetProtocol

func (p *HeaderProtocol) ResetProtocol() error

func (*HeaderProtocol) SetHeader

func (p *HeaderProtocol) SetHeader(key, value string)

func (*HeaderProtocol) SetIdentity

func (p *HeaderProtocol) SetIdentity(identity string)

func (*HeaderProtocol) SetPersistentHeader

func (p *HeaderProtocol) SetPersistentHeader(key, value string)

func (*HeaderProtocol) Skip

func (p *HeaderProtocol) Skip(fieldType Type) (err error)

func (*HeaderProtocol) Transport

func (p *HeaderProtocol) Transport() Transport

func (*HeaderProtocol) WriteMessageBegin

func (p *HeaderProtocol) WriteMessageBegin(name string, typeId MessageType, seqid int32) error

type HeaderProtocolFactory

type HeaderProtocolFactory struct{}

func NewHeaderProtocolFactory

func NewHeaderProtocolFactory() *HeaderProtocolFactory

func (*HeaderProtocolFactory) GetProtocol

func (p *HeaderProtocolFactory) GetProtocol(trans Transport) Protocol

type HeaderTransport

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

func NewHeaderTransport

func NewHeaderTransport(transport Transport) *HeaderTransport

NewHeaderTransport Create a new transport with defaults.

func (*HeaderTransport) AddTransform

func (t *HeaderTransport) AddTransform(trans TransformID) error

func (*HeaderTransport) ClearHeaders

func (t *HeaderTransport) ClearHeaders()

func (*HeaderTransport) ClearPersistentHeaders

func (t *HeaderTransport) ClearPersistentHeaders()

func (*HeaderTransport) Close

func (t *HeaderTransport) Close() error

Close Close the internal transport

func (*HeaderTransport) Flush

func (t *HeaderTransport) Flush() error

func (*HeaderTransport) GetFlags

func (t *HeaderTransport) GetFlags() HeaderFlags

GetFlags returns the header flags.

func (*HeaderTransport) Header

func (t *HeaderTransport) Header(key string) (string, bool)

func (*HeaderTransport) Headers

func (t *HeaderTransport) Headers() map[string]string

func (*HeaderTransport) Identity

func (t *HeaderTransport) Identity() string

func (*HeaderTransport) IsOpen

func (t *HeaderTransport) IsOpen() bool

IsOpen Is the current transport open

func (*HeaderTransport) Open

func (t *HeaderTransport) Open() error

Open Open the internal transport

func (*HeaderTransport) PeerIdentity

func (t *HeaderTransport) PeerIdentity() string

func (*HeaderTransport) PersistentHeader

func (t *HeaderTransport) PersistentHeader(key string) (string, bool)

func (*HeaderTransport) PersistentHeaders

func (t *HeaderTransport) PersistentHeaders() map[string]string

func (*HeaderTransport) ProtocolID

func (t *HeaderTransport) ProtocolID() ProtocolID

func (*HeaderTransport) Read

func (t *HeaderTransport) Read(buf []byte) (int, error)

Read Read from the current framebuffer. EOF if the frame is done.

func (*HeaderTransport) ReadByte

func (t *HeaderTransport) ReadByte() (byte, error)

ReadByte Read a single byte from the current framebuffer. EOF if the frame is done.

func (*HeaderTransport) ReadHeader

func (t *HeaderTransport) ReadHeader(key string) (string, bool)

func (*HeaderTransport) ReadHeaders

func (t *HeaderTransport) ReadHeaders() map[string]string

func (*HeaderTransport) RemainingBytes

func (t *HeaderTransport) RemainingBytes() uint64

RemainingBytes Return how many bytes remain in the current recv framebuffer.

func (*HeaderTransport) ResetProtocol

func (t *HeaderTransport) ResetProtocol() error

ResetProtocol Needs to be called between every frame receive (BeginMessageRead) We do this to read out the header for each frame. This contains the length of the frame and protocol / metadata info.

func (*HeaderTransport) SeqID

func (t *HeaderTransport) SeqID() uint32

func (*HeaderTransport) SetFlags

func (t *HeaderTransport) SetFlags(flags HeaderFlags)

SetFlags sets the header flags.

func (*HeaderTransport) SetHeader

func (t *HeaderTransport) SetHeader(key, value string)

func (*HeaderTransport) SetIdentity

func (t *HeaderTransport) SetIdentity(identity string)

func (*HeaderTransport) SetPersistentHeader

func (t *HeaderTransport) SetPersistentHeader(key, value string)

func (*HeaderTransport) SetProtocolID

func (t *HeaderTransport) SetProtocolID(protoID ProtocolID) error

func (*HeaderTransport) SetSeqID

func (t *HeaderTransport) SetSeqID(seq uint32)

func (*HeaderTransport) UnderlyingTransport

func (t *HeaderTransport) UnderlyingTransport() Transport

UnderlyingTransport Get the underlying transport

func (*HeaderTransport) Write

func (t *HeaderTransport) Write(buf []byte) (int, error)

Write Write multiple bytes to the framebuffer, does not send to transport.

func (*HeaderTransport) WriteByte

func (t *HeaderTransport) WriteByte(c byte) error

WriteByte Write a single byte to the framebuffer, does not send to transport.

func (*HeaderTransport) WriteString

func (t *HeaderTransport) WriteString(s string) (int, error)

WriteString Write a string to the framebuffer, does not send to transport.

type IRequest

type IRequest interface {
	Write(p Protocol) error
}

IRequest represents a request to be sent to a thrift endpoint

type IResponse

type IResponse interface {
	Read(p Protocol) error
}

IResponse represents a response received from a thrift call

type Identity

type Identity struct {
	Type string
	Data string
}

Identity represents a secure peer identity

type InfoIDType

type InfoIDType uint32
const (
	InfoIDPadding   InfoIDType = 0
	InfoIDKeyValue  InfoIDType = 1
	InfoIDPKeyValue InfoIDType = 2
)

type Interceptor

type Interceptor func(ctx context.Context, methodName string, pfunc ProcessorFunctionContext, args Struct) (WritableStruct, ApplicationException)

Interceptor is a function that runs before the actual method. It is passed the connection context, the method name and the args for that method. The interceptor is responsible for calling pfunc.RunContext() and it can return a result or an exception which are then sent back to the caller. The interceptor is expected to be concurrency safe.

type JSONProtocol

type JSONProtocol struct {
	*SimpleJSONProtocol
}

JSONProtocol is the Compact JSON protocol implementation for thrift.

This protocol produces/consumes a compact JSON output with field numbers as object keys and field values lightly encoded.

Example: With the Message definition

struct Message {
  1: bool aBool
  2: map<string, bool> aBoolStringMap
},

Message(aBool=True, aBoolStringMap={"key1": True, "key2": False})

will be encoded as:

{"1":{"tf":1},"2":{"map":["str","tf",2,{"key1": 1,"key2":0}]}}'

func NewJSONProtocol

func NewJSONProtocol(t Transport) *JSONProtocol

Constructor

func (*JSONProtocol) Flush

func (p *JSONProtocol) Flush() (err error)

func (*JSONProtocol) OutputElemListBegin

func (p *JSONProtocol) OutputElemListBegin(elemType Type, size int) error

func (*JSONProtocol) ParseElemListBegin

func (p *JSONProtocol) ParseElemListBegin() (elemType Type, size int, e error)

func (*JSONProtocol) ReadBinary

func (p *JSONProtocol) ReadBinary() ([]byte, error)

func (*JSONProtocol) ReadBool

func (p *JSONProtocol) ReadBool() (bool, error)

func (*JSONProtocol) ReadByte

func (p *JSONProtocol) ReadByte() (byte, error)

func (*JSONProtocol) ReadDouble

func (p *JSONProtocol) ReadDouble() (float64, error)

func (*JSONProtocol) ReadFieldBegin

func (p *JSONProtocol) ReadFieldBegin() (string, Type, int16, error)

func (*JSONProtocol) ReadFieldEnd

func (p *JSONProtocol) ReadFieldEnd() error

func (*JSONProtocol) ReadFloat

func (p *JSONProtocol) ReadFloat() (float32, error)

func (*JSONProtocol) ReadI16

func (p *JSONProtocol) ReadI16() (int16, error)

func (*JSONProtocol) ReadI32

func (p *JSONProtocol) ReadI32() (int32, error)

func (*JSONProtocol) ReadI64

func (p *JSONProtocol) ReadI64() (int64, error)

func (*JSONProtocol) ReadListBegin

func (p *JSONProtocol) ReadListBegin() (elemType Type, size int, e error)

func (*JSONProtocol) ReadListEnd

func (p *JSONProtocol) ReadListEnd() error

func (*JSONProtocol) ReadMapBegin

func (p *JSONProtocol) ReadMapBegin() (keyType Type, valueType Type, size int, e error)

func (*JSONProtocol) ReadMapEnd

func (p *JSONProtocol) ReadMapEnd() error

func (*JSONProtocol) ReadMessageBegin

func (p *JSONProtocol) ReadMessageBegin() (name string, typeId MessageType, seqId int32, err error)

Reading methods.

func (*JSONProtocol) ReadMessageEnd

func (p *JSONProtocol) ReadMessageEnd() error

func (*JSONProtocol) ReadSetBegin

func (p *JSONProtocol) ReadSetBegin() (elemType Type, size int, e error)

func (*JSONProtocol) ReadSetEnd

func (p *JSONProtocol) ReadSetEnd() error

func (*JSONProtocol) ReadString

func (p *JSONProtocol) ReadString() (string, error)

func (*JSONProtocol) ReadStructBegin

func (p *JSONProtocol) ReadStructBegin() (name string, err error)

func (*JSONProtocol) ReadStructEnd

func (p *JSONProtocol) ReadStructEnd() error

func (*JSONProtocol) Skip

func (p *JSONProtocol) Skip(fieldType Type) (err error)

func (*JSONProtocol) StringToTypeId

func (p *JSONProtocol) StringToTypeId(fieldType string) (Type, error)

func (*JSONProtocol) Transport

func (p *JSONProtocol) Transport() Transport

func (*JSONProtocol) TypeIdToString

func (p *JSONProtocol) TypeIdToString(fieldType Type) (string, error)

func (*JSONProtocol) WriteBinary

func (p *JSONProtocol) WriteBinary(v []byte) error

func (*JSONProtocol) WriteBool

func (p *JSONProtocol) WriteBool(b bool) error

func (*JSONProtocol) WriteByte

func (p *JSONProtocol) WriteByte(b byte) error

func (*JSONProtocol) WriteDouble

func (p *JSONProtocol) WriteDouble(v float64) error

func (*JSONProtocol) WriteFieldBegin

func (p *JSONProtocol) WriteFieldBegin(name string, typeId Type, id int16) error

func (*JSONProtocol) WriteFieldEnd

func (p *JSONProtocol) WriteFieldEnd() error

func (*JSONProtocol) WriteFieldStop

func (p *JSONProtocol) WriteFieldStop() error

func (*JSONProtocol) WriteFloat

func (p *JSONProtocol) WriteFloat(v float32) error

func (*JSONProtocol) WriteI16

func (p *JSONProtocol) WriteI16(v int16) error

func (*JSONProtocol) WriteI32

func (p *JSONProtocol) WriteI32(v int32) error

func (*JSONProtocol) WriteI64

func (p *JSONProtocol) WriteI64(v int64) error

func (*JSONProtocol) WriteListBegin

func (p *JSONProtocol) WriteListBegin(elemType Type, size int) error

func (*JSONProtocol) WriteListEnd

func (p *JSONProtocol) WriteListEnd() error

func (*JSONProtocol) WriteMapBegin

func (p *JSONProtocol) WriteMapBegin(keyType Type, valueType Type, size int) error

func (*JSONProtocol) WriteMapEnd

func (p *JSONProtocol) WriteMapEnd() error

func (*JSONProtocol) WriteMessageBegin

func (p *JSONProtocol) WriteMessageBegin(name string, typeId MessageType, seqId int32) error

func (*JSONProtocol) WriteMessageEnd

func (p *JSONProtocol) WriteMessageEnd() error

func (*JSONProtocol) WriteSetBegin

func (p *JSONProtocol) WriteSetBegin(elemType Type, size int) error

func (*JSONProtocol) WriteSetEnd

func (p *JSONProtocol) WriteSetEnd() error

func (*JSONProtocol) WriteString

func (p *JSONProtocol) WriteString(v string) error

func (*JSONProtocol) WriteStructBegin

func (p *JSONProtocol) WriteStructBegin(name string) error

func (*JSONProtocol) WriteStructEnd

func (p *JSONProtocol) WriteStructEnd() error

type JSONProtocolFactory

type JSONProtocolFactory struct{}

Factory

func NewJSONProtocolFactory

func NewJSONProtocolFactory() *JSONProtocolFactory

func (*JSONProtocolFactory) GetProtocol

func (p *JSONProtocolFactory) GetProtocol(trans Transport) Protocol

type MemoryBuffer

type MemoryBuffer struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

Memory buffer-based implementation of the Transport interface.

func NewMemoryBuffer

func NewMemoryBuffer() *MemoryBuffer

func NewMemoryBufferLen

func NewMemoryBufferLen(size int) *MemoryBuffer

func NewMemoryBufferWithData

func NewMemoryBufferWithData(data []byte) *MemoryBuffer

func (*MemoryBuffer) Close

func (p *MemoryBuffer) Close() error

func (*MemoryBuffer) Flush

func (p *MemoryBuffer) Flush() error

Flushing a memory buffer is a no-op

func (*MemoryBuffer) IsOpen

func (p *MemoryBuffer) IsOpen() bool

func (*MemoryBuffer) Open

func (p *MemoryBuffer) Open() error

func (*MemoryBuffer) RemainingBytes

func (p *MemoryBuffer) RemainingBytes() (num_bytes uint64)

type MemoryBufferTransportFactory

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

func NewMemoryBufferTransportFactory

func NewMemoryBufferTransportFactory(size int) *MemoryBufferTransportFactory

func (*MemoryBufferTransportFactory) GetTransport

func (p *MemoryBufferTransportFactory) GetTransport(trans Transport) Transport

type MessageType

type MessageType int32

Message type constants in the Thrift protocol.

const (
	INVALID_MESSAGE_TYPE MessageType = 0
	CALL                 MessageType = 1
	REPLY                MessageType = 2
	EXCEPTION            MessageType = 3
	ONEWAY               MessageType = 4
)

type MultiplexedProcessor

type MultiplexedProcessor struct {
	Defaulprocessor Processor
	// contains filtered or unexported fields
}

func NewMultiplexedProcessor

func NewMultiplexedProcessor() *MultiplexedProcessor

func (*MultiplexedProcessor) GetProcessorFunction

func (t *MultiplexedProcessor) GetProcessorFunction(name string) (ProcessorFunction, error)

GetProcessorFunction implements the thrift.Processor interface. It parses the thrift function name to figure out which processor to route the request to and returns descriptive error messages to help clients diagnose errors.

func (*MultiplexedProcessor) RegisterDefault

func (t *MultiplexedProcessor) RegisterDefault(processor Processor)

func (*MultiplexedProcessor) RegisterProcessor

func (t *MultiplexedProcessor) RegisterProcessor(name string, processor Processor)

type MultiplexedProtocol

type MultiplexedProtocol struct {
	Protocol
	// contains filtered or unexported fields
}

func NewMultiplexedProtocol

func NewMultiplexedProtocol(protocol Protocol, serviceName string) *MultiplexedProtocol

func (*MultiplexedProtocol) WriteMessageBegin

func (t *MultiplexedProtocol) WriteMessageBegin(name string, typeId MessageType, seqid int32) error

type Numeric

type Numeric interface {
	Int64() int64
	Int32() int32
	Int16() int16
	Byte() byte
	Int() int
	Float64() float64
	Float32() float32
	String() string
	// contains filtered or unexported methods
}
var (
	INFINITY          Numeric = &numeric{iValue: 0, dValue: math.Inf(1), sValue: "Infinity", isNil: false}
	NEGATIVE_INFINITY Numeric = &numeric{iValue: 0, dValue: math.Inf(-1), sValue: "-Infinity", isNil: false}
	NAN               Numeric = &numeric{iValue: 0, dValue: math.NaN(), sValue: "NaN", isNil: false}
	ZERO              Numeric = &numeric{iValue: 0, dValue: 0, sValue: "0", isNil: false}
	NUMERIC_NULL      Numeric = &numeric{iValue: 0, dValue: 0, sValue: "0", isNil: true}
)

func NewNullNumeric

func NewNullNumeric() Numeric

func NewNumericFromDouble

func NewNumericFromDouble(dValue float64) Numeric

func NewNumericFromFloat

func NewNumericFromFloat(dValue float32) Numeric

func NewNumericFromI32

func NewNumericFromI32(iValue int32) Numeric

func NewNumericFromI64

func NewNumericFromI64(iValue int64) Numeric

func NewNumericFromJSONString

func NewNumericFromJSONString(sValue string, isNull bool) Numeric

func NewNumericFromString

func NewNumericFromString(sValue string) Numeric

type Priority

type Priority uint8

Priority maps to C++ apache::thrift::concurrency::PRIORITY

const (
	PriorityNone          Priority = 0
	PriorityHighImportant Priority = 1
	PriorityHigh          Priority = 2
	PriorityImportant     Priority = 3
	PriorityNormal        Priority = 4
	PriorityBestEffort    Priority = 5
	PriorityEnd           Priority = 6
)

Priority maps to C++ apache::thrift::concurrency::PRIORITY

type Processor

type Processor interface {
	// GetProcessorFunction is given the name of a thrift function and
	// the type of the inbound thrift message.  It is expected to return
	// a non-nil ProcessorFunction when the function can be successfully
	// found.
	//
	// If an error is returned, it will be wrapped in an application level
	// thrift exception and returned.
	//
	// If ProcessorFunction and error are both nil, a generic error will be
	// sent which explains that no processor function exists with the specified
	// name on this server.
	GetProcessorFunction(name string) (ProcessorFunction, error)
}

Processor exposes access to processor functions which manage I/O and processing of a input message for a specific server function

func WrapInterceptor

func WrapInterceptor(interceptor Interceptor, p Processor) Processor

WrapInterceptor wraps an interceptor around the Processor p such as when running the method returned by that processor it will execute the interceptor instead. The interceptor is executed with context.Background() as its context.

type ProcessorContext

type ProcessorContext interface {
	GetProcessorFunctionContext(name string) (ProcessorFunctionContext, error)
}

ProcessorContext is a Processor that supports contexts.

func NewProcessorContextAdapter

func NewProcessorContextAdapter(p Processor) ProcessorContext

NewProcessorContextAdapter creates a ProcessorContext from a regular Processor.

func WrapInterceptorContext

func WrapInterceptorContext(interceptor Interceptor, p ProcessorContext) ProcessorContext

WrapInterceptorContext wraps an interceptor around the ProcessorContext p such as when running the method returned by that processor it will execute the interceptor instead.

type ProcessorFactory

type ProcessorFactory interface {
	GetProcessor(trans Transport) Processor
}

ProcessorFactory is the default processor factory which returns a singleton instance.

func NewProcessorFactory

func NewProcessorFactory(p Processor) ProcessorFactory

NewProcessorFactory returns a ProcessorFactory.

type ProcessorFactoryContext

type ProcessorFactoryContext interface {
	GetProcessorContext(trans Transport) ProcessorContext
}

ProcessorFactoryContext is a ProcessorFactory that supports contexts.

func NewProcessorFactoryContext

func NewProcessorFactoryContext(p ProcessorContext) ProcessorFactoryContext

NewProcessorFactoryContext returns a ProcessorFactoryContext.

func NewProcessorFactoryContextAdapter

func NewProcessorFactoryContextAdapter(p ProcessorFactory) ProcessorFactoryContext

NewProcessorFactoryContextAdapter creates a ProcessorFactoryContext from a regular ProcessorFactory.

type ProcessorFunction

type ProcessorFunction interface {
	// Read a serializable message from the input protocol.
	Read(iprot Protocol) (Struct, Exception)
	// Process a message handing it to the client handler.
	Run(args Struct) (WritableStruct, ApplicationException)
	// Write a serializable responsne
	Write(seqID int32, result WritableStruct, oprot Protocol) Exception
}

ProcessorFunction is the interface that must be implemented in order to perform io and message processing

type ProcessorFunctionContext

type ProcessorFunctionContext interface {
	Read(iprot Protocol) (Struct, Exception)
	RunContext(ctx context.Context, args Struct) (WritableStruct, ApplicationException)
	Write(seqID int32, result WritableStruct, oprot Protocol) Exception
}

ProcessorFunctionContext is a ProcessorFunction that supports contexts.

func NewProcessorFunctionContextAdapter

func NewProcessorFunctionContextAdapter(p ProcessorFunction) ProcessorFunctionContext

NewProcessorFunctionContextAdapter creates a ProcessorFunctionContext from a regular ProcessorFunction.

type ProcessorFunctionFactory

type ProcessorFunctionFactory interface {
	GetProcessorFunction(trans Transport) ProcessorFunction
}

*

  • The default processor factory just returns a singleton
  • instance.

type Protocol

type Protocol interface {
	WriteMessageBegin(name string, typeId MessageType, seqid int32) error
	WriteMessageEnd() error
	WriteStructBegin(name string) error
	WriteStructEnd() error
	WriteFieldBegin(name string, typeId Type, id int16) error
	WriteFieldEnd() error
	WriteFieldStop() error
	WriteMapBegin(keyType Type, valueType Type, size int) error
	WriteMapEnd() error
	WriteListBegin(elemType Type, size int) error
	WriteListEnd() error
	WriteSetBegin(elemType Type, 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
	WriteFloat(value float32) error
	WriteString(value string) error
	WriteBinary(value []byte) error

	ReadMessageBegin() (name string, typeId MessageType, seqid int32, err error)
	ReadMessageEnd() error
	ReadStructBegin() (name string, err error)
	ReadStructEnd() error
	ReadFieldBegin() (name string, typeId Type, id int16, err error)
	ReadFieldEnd() error
	ReadMapBegin() (keyType Type, valueType Type, size int, err error)
	ReadMapEnd() error
	ReadListBegin() (elemType Type, size int, err error)
	ReadListEnd() error
	ReadSetBegin() (elemType Type, size int, err error)
	ReadSetEnd() error
	ReadBool() (value bool, err error)
	ReadByte() (value byte, err error)
	ReadI16() (value int16, err error)
	ReadI32() (value int32, err error)
	ReadI64() (value int64, err error)
	ReadDouble() (value float64, err error)
	ReadFloat() (value float32, err error)
	ReadString() (value string, err error)
	ReadBinary() (value []byte, err error)

	Skip(fieldType Type) (err error)
	Flush() (err error)

	Transport() Transport
}

type ProtocolException

type ProtocolException interface {
	Exception
	TypeID() int
}

ProtocolException is the thrift protocol exception

func NewProtocolException

func NewProtocolException(err error) ProtocolException

NewProtocolException creates a new ProtocolException

func NewProtocolExceptionWithType

func NewProtocolExceptionWithType(errType int, err error) ProtocolException

NewProtocolExceptionWithType create a new ProtocolException with an error type

type ProtocolFactory

type ProtocolFactory interface {
	GetProtocol(trans Transport) Protocol
}

Factory interface for constructing protocol instances.

type ProtocolID

type ProtocolID int16
const (
	ProtocolIDBinary     ProtocolID = 0
	ProtocolIDJSON       ProtocolID = 1
	ProtocolIDCompact    ProtocolID = 2
	ProtocolIDDebug      ProtocolID = 3
	ProtocolIDVirtual    ProtocolID = 4
	ProtocolIDSimpleJSON ProtocolID = 5
)

func (ProtocolID) String

func (p ProtocolID) String() string

type RPCOptions

type RPCOptions struct {
	Timeout            time.Duration
	ChunkTimeout       time.Duration
	QueueTimeout       time.Duration
	OverallTimeout     time.Duration
	ProcessingTimeout  time.Duration
	Priority           Priority
	ClientOnlyTimeouts bool
	InteractionID      int64
	// contains filtered or unexported fields
}

RPCOptions is a mirror of C++ apache::thrift::RPCOptions Not all options are guaranteed to be implemented by a client

func GetRPCOptions

func GetRPCOptions(ctx context.Context) *RPCOptions

GetRPCOptions returns the RPCOptions in a go context, or nil if there is nothing

func (*RPCOptions) GetReadHeader

func (c *RPCOptions) GetReadHeader(k string) (string, bool)

func (*RPCOptions) GetWriteHeader

func (c *RPCOptions) GetWriteHeader(k string) (string, bool)

func (*RPCOptions) ReadHeaders

func (c *RPCOptions) ReadHeaders() map[string]string

func (*RPCOptions) SetReadHeader

func (c *RPCOptions) SetReadHeader(k, v string)

func (*RPCOptions) SetReadHeaders

func (c *RPCOptions) SetReadHeaders(headers map[string]string)

func (*RPCOptions) SetWriteHeader

func (c *RPCOptions) SetWriteHeader(k, v string)

func (*RPCOptions) SetWriteHeaders

func (c *RPCOptions) SetWriteHeaders(headers map[string]string)

func (*RPCOptions) WriteHeaders

func (c *RPCOptions) WriteHeaders() map[string]string

type ReadSizeProvider

type ReadSizeProvider interface {
	RemainingBytes() (numBytes uint64)
}

ReadSizeProvider is the interface that wraps the basic RemainingBytes method

type RequestChannel

type RequestChannel interface {
	ClientInterface

	Call(ctx context.Context, method string, request IRequest, response IResponse) error
	Oneway(ctx context.Context, method string, request IRequest) error
}

RequestChannel is an API that implements the most minimal surface for generated client code. An implementation:

  • Must be thread-safe
  • May implement request pipelining
  • May implement reconnection logic
  • May implement connection pooling
  • Hides implementation details of the protocol and transport.

type RequestContext

type RequestContext struct {
	RequestTimeout time.Duration
	Method         string
	SequenceID     int32
	InteractionID  int64
	Priority       Priority

	LocalAddress     net.Addr
	PeerAddress      net.Addr
	SecurityProtocol string
	PeerIdentities   []Identity
	PeerCommonName   string
	// contains filtered or unexported fields
}

RequestContext is a mirror of C++ apache::thrift::RPCOptions Not all options are guaranteed to be implemented by a client

func GetRequestContext

func GetRequestContext(ctx context.Context) *RequestContext

GetRequestContext returns the RequestContext in a go context, or nil if there is nothing

func (*RequestContext) GetReadHeader

func (c *RequestContext) GetReadHeader(k string) (string, bool)

func (*RequestContext) GetWriteHeader

func (c *RequestContext) GetWriteHeader(k string) (string, bool)

func (*RequestContext) ReadHeaders

func (c *RequestContext) ReadHeaders() map[string]string

func (*RequestContext) SetReadHeader

func (c *RequestContext) SetReadHeader(k, v string)

func (*RequestContext) SetReadHeaders

func (c *RequestContext) SetReadHeaders(headers map[string]string)

func (*RequestContext) SetWriteHeader

func (c *RequestContext) SetWriteHeader(k, v string)

func (*RequestContext) SetWriteHeaders

func (c *RequestContext) SetWriteHeaders(headers map[string]string)

func (*RequestContext) WriteHeaders

func (c *RequestContext) WriteHeaders() map[string]string

type RichTransport

type RichTransport interface {
	io.ReadWriter
	io.ByteReader
	io.ByteWriter

	Flusher
	ReadSizeProvider
	// contains filtered or unexported methods
}

RichTransport is an "enhanced" transport with extra capabilities. You need to use one of these to construct protocol. Notably, Socket does not implement this interface, and it is always a mistake to use Socket directly in protocol.

func NewRichTransport

func NewRichTransport(trans Transport) RichTransport

Wraps Transport to provide RichTransport interface

type SSLServerSocket

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

func NewSSLServerSocket

func NewSSLServerSocket(listenAddr string, cfg *tls.Config) (*SSLServerSocket, error)

func NewSSLServerSocketTimeout

func NewSSLServerSocketTimeout(listenAddr string, cfg *tls.Config, clientTimeout time.Duration) (*SSLServerSocket, error)

func (*SSLServerSocket) Accept

func (p *SSLServerSocket) Accept() (Transport, error)

func (*SSLServerSocket) Addr

func (p *SSLServerSocket) Addr() net.Addr

func (*SSLServerSocket) Close

func (p *SSLServerSocket) Close() error

func (*SSLServerSocket) Interrupt

func (p *SSLServerSocket) Interrupt() error

func (*SSLServerSocket) IsListening

func (p *SSLServerSocket) IsListening() bool

Checks whether the socket is listening.

func (*SSLServerSocket) Listen

func (p *SSLServerSocket) Listen() error

func (*SSLServerSocket) Open

func (p *SSLServerSocket) Open() error

Connects the socket, creating a new socket object if necessary.

type SSLSocket

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

func NewSSLSocket

func NewSSLSocket(hostPort string, cfg *tls.Config) (*SSLSocket, error)

NewSSLSocket creates a net.Conn-backed Transport, given a host and port and tls Configuration

Example:

trans, err := thrift.NewSSLSocket("localhost:9090", nil)

func NewSSLSocketFromAddrTimeout

func NewSSLSocketFromAddrTimeout(addr net.Addr, cfg *tls.Config, timeout time.Duration) *SSLSocket

Creates a SSLSocket from a net.Addr

func NewSSLSocketFromConnTimeout

func NewSSLSocketFromConnTimeout(conn net.Conn, cfg *tls.Config, timeout time.Duration) *SSLSocket

Creates a SSLSocket from an existing net.Conn

func NewSSLSocketTimeout

func NewSSLSocketTimeout(hostPort string, cfg *tls.Config, timeout time.Duration) (*SSLSocket, error)

NewSSLSocketTimeout creates a net.Conn-backed Transport, given a host and port it also accepts a tls Configuration and a timeout as a time.Duration

func (*SSLSocket) Close

func (p *SSLSocket) Close() error

Closes the socket.

func (*SSLSocket) Conn

func (p *SSLSocket) Conn() net.Conn

Retrieve the underlying net.Conn

func (*SSLSocket) Flush

func (p *SSLSocket) Flush() error

func (*SSLSocket) Interrupt

func (p *SSLSocket) Interrupt() error

func (*SSLSocket) IsOpen

func (p *SSLSocket) IsOpen() bool

Returns true if the connection is open

func (*SSLSocket) Open

func (p *SSLSocket) Open() error

Connects the socket, creating a new socket object if necessary.

func (*SSLSocket) Read

func (p *SSLSocket) Read(buf []byte) (int, error)

func (*SSLSocket) RemainingBytes

func (p *SSLSocket) RemainingBytes() (num_bytes uint64)

func (*SSLSocket) SetTimeout

func (p *SSLSocket) SetTimeout(timeout time.Duration) error

Sets the socket timeout

func (*SSLSocket) Write

func (p *SSLSocket) Write(buf []byte) (int, error)

type SerialChannel

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

SerialChannel is a simple threadsafe channel which allows for a single request-response to occur at once. Head of line blocking can occur with this channel.

func NewSerialChannel

func NewSerialChannel(protocol Protocol) *SerialChannel

NewSerialChannel creates a new serial channel. The protocol should already be open.

func (*SerialChannel) Call

func (c *SerialChannel) Call(ctx context.Context, method string, request IRequest, response IResponse) error

Call will call the given method with the given thrift struct, and read the response into the given response struct. It only allows one outstanding request at once, but is thread-safe.

func (*SerialChannel) Close

func (c *SerialChannel) Close() error

Close closes the client connection

func (*SerialChannel) IsOpen

func (c *SerialChannel) IsOpen() bool

IsOpen return true if the client connection is open; otherwise, it returns false.

func (*SerialChannel) Oneway

func (c *SerialChannel) Oneway(ctx context.Context, method string, request IRequest) error

Oneway will call the given method with the given thrift struct. It returns immediately when the request is sent. It only allows one outstanding request at once, but is thread-safe.

func (*SerialChannel) Open

func (c *SerialChannel) Open() error

Open opens the client connection

type Serializer

type Serializer struct {
	Transport *MemoryBuffer
	Protocol  Protocol
}

A Serializer is used to turn a Struct in to a byte stream

func NewCompactSerializer

func NewCompactSerializer() *Serializer

NewCompactSerializer creates a new serializer using the compact protocol

func NewJSONSerializer

func NewJSONSerializer() *Serializer

NewJSONSerializer creates a new serializer using the JSON protocol

func NewSerializer

func NewSerializer() *Serializer

NewSerializer create a new serializer using the binary protocol

func NewSimpleJSONSerializer

func NewSimpleJSONSerializer() *Serializer

NewSimpleJSONSerializer creates a new serializer using the SimpleJSON protocol

func (*Serializer) Write

func (s *Serializer) Write(msg Struct) (b []byte, err error)

Write writes msg to the serializer and returns it as a byte array

func (*Serializer) WriteString

func (s *Serializer) WriteString(msg Struct) (str string, err error)

WriteString writes msg to the serializer and returns it as a string

type Server

type Server interface {
	ProcessorFactoryContext() ProcessorFactoryContext
	ServerTransport() ServerTransport
	InputTransportFactory() TransportFactory
	OutputTransportFactory() TransportFactory
	InputProtocolFactory() ProtocolFactory
	OutputProtocolFactory() ProtocolFactory

	// Serve starts the server
	Serve() error
	// ServeContext starts the server, and stops it when the context is cancelled
	ServeContext(ctx context.Context) error
	// Stop stops the server. This is optional on a per-implementation basis. Not
	// all servers are required to be cleanly stoppable.
	Stop() error
}

Server is a thrift server

type ServerOptions

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

ServerOptions is options needed to run a thrift server

type ServerSocket

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

func NewServerSocket

func NewServerSocket(listenAddr string) (*ServerSocket, error)

func NewServerSocketTimeout

func NewServerSocketTimeout(listenAddr string, clientTimeout time.Duration) (*ServerSocket, error)

func (*ServerSocket) Accept

func (p *ServerSocket) Accept() (Transport, error)

func (*ServerSocket) Addr

func (p *ServerSocket) Addr() net.Addr

func (*ServerSocket) Close

func (p *ServerSocket) Close() error

func (*ServerSocket) Interrupt

func (p *ServerSocket) Interrupt() error

func (*ServerSocket) IsListening

func (p *ServerSocket) IsListening() bool

Checks whether the socket is listening.

func (*ServerSocket) Listen

func (p *ServerSocket) Listen() error

func (*ServerSocket) Open

func (p *ServerSocket) Open() error

Connects the socket, creating a new socket object if necessary.

type ServerTransport

type ServerTransport interface {
	Listen() error
	Accept() (Transport, error)
	Close() error

	// Optional method implementation. This signals to the server transport
	// that it should break out of any accept() or listen() that it is currently
	// blocked on. This method, if implemented, MUST be thread safe, as it may
	// be called from a different thread context than the other ServerTransport
	// methods.
	Interrupt() error
}

Server transport. Object which provides client transports.

type SimpleJSONProtocol

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

JSON protocol implementation for thrift.

This protocol produces/consumes a simple output format suitable for parsing by scripting languages. It should not be confused with the full-featured JSONProtocol.

func NewSimpleJSONProtocol

func NewSimpleJSONProtocol(t Transport) *SimpleJSONProtocol

Constructor

func (*SimpleJSONProtocol) Flush

func (p *SimpleJSONProtocol) Flush() (err error)

func (*SimpleJSONProtocol) OutputBool

func (p *SimpleJSONProtocol) OutputBool(value bool) error

func (*SimpleJSONProtocol) OutputElemListBegin

func (p *SimpleJSONProtocol) OutputElemListBegin(elemType Type, size int) error

func (*SimpleJSONProtocol) OutputF32

func (p *SimpleJSONProtocol) OutputF32(value float32) error

func (*SimpleJSONProtocol) OutputF64

func (p *SimpleJSONProtocol) OutputF64(value float64) error

func (*SimpleJSONProtocol) OutputI64

func (p *SimpleJSONProtocol) OutputI64(value int64) error

func (*SimpleJSONProtocol) OutputListBegin

func (p *SimpleJSONProtocol) OutputListBegin() error

func (*SimpleJSONProtocol) OutputListEnd

func (p *SimpleJSONProtocol) OutputListEnd() error

func (*SimpleJSONProtocol) OutputNull

func (p *SimpleJSONProtocol) OutputNull() error

func (*SimpleJSONProtocol) OutputObjectBegin

func (p *SimpleJSONProtocol) OutputObjectBegin() error

func (*SimpleJSONProtocol) OutputObjectEnd

func (p *SimpleJSONProtocol) OutputObjectEnd() error

func (*SimpleJSONProtocol) OutputPostValue

func (p *SimpleJSONProtocol) OutputPostValue() error

func (*SimpleJSONProtocol) OutputPreValue

func (p *SimpleJSONProtocol) OutputPreValue() error

func (*SimpleJSONProtocol) OutputString

func (p *SimpleJSONProtocol) OutputString(s string) error

func (*SimpleJSONProtocol) OutputStringData

func (p *SimpleJSONProtocol) OutputStringData(s string) error

func (*SimpleJSONProtocol) ParseBase64EncodedBody

func (p *SimpleJSONProtocol) ParseBase64EncodedBody() ([]byte, error)

func (*SimpleJSONProtocol) ParseElemListBegin

func (p *SimpleJSONProtocol) ParseElemListBegin() (elemType Type, size int, e error)

func (*SimpleJSONProtocol) ParseF32

func (p *SimpleJSONProtocol) ParseF32() (float32, bool, error)

func (*SimpleJSONProtocol) ParseF64

func (p *SimpleJSONProtocol) ParseF64() (float64, bool, error)

func (*SimpleJSONProtocol) ParseI64

func (p *SimpleJSONProtocol) ParseI64() (int64, bool, error)

func (*SimpleJSONProtocol) ParseListBegin

func (p *SimpleJSONProtocol) ParseListBegin() (isNull bool, err error)

func (*SimpleJSONProtocol) ParseListEnd

func (p *SimpleJSONProtocol) ParseListEnd() error

func (*SimpleJSONProtocol) ParseObjectEnd

func (p *SimpleJSONProtocol) ParseObjectEnd() error

func (*SimpleJSONProtocol) ParseObjectStart

func (p *SimpleJSONProtocol) ParseObjectStart() (bool, error)

func (*SimpleJSONProtocol) ParsePostValue

func (p *SimpleJSONProtocol) ParsePostValue() error

func (*SimpleJSONProtocol) ParsePreValue

func (p *SimpleJSONProtocol) ParsePreValue() error

func (*SimpleJSONProtocol) ParseQuotedStringBody

func (p *SimpleJSONProtocol) ParseQuotedStringBody() (string, error)

func (*SimpleJSONProtocol) ParseStringBody

func (p *SimpleJSONProtocol) ParseStringBody() (string, error)

func (*SimpleJSONProtocol) ReadBinary

func (p *SimpleJSONProtocol) ReadBinary() ([]byte, error)

func (*SimpleJSONProtocol) ReadBool

func (p *SimpleJSONProtocol) ReadBool() (bool, error)

func (*SimpleJSONProtocol) ReadByte

func (p *SimpleJSONProtocol) ReadByte() (byte, error)

func (*SimpleJSONProtocol) ReadDouble

func (p *SimpleJSONProtocol) ReadDouble() (float64, error)

func (*SimpleJSONProtocol) ReadFieldBegin

func (p *SimpleJSONProtocol) ReadFieldBegin() (string, Type, int16, error)

func (*SimpleJSONProtocol) ReadFieldEnd

func (p *SimpleJSONProtocol) ReadFieldEnd() error

func (*SimpleJSONProtocol) ReadFloat

func (p *SimpleJSONProtocol) ReadFloat() (float32, error)

func (*SimpleJSONProtocol) ReadI16

func (p *SimpleJSONProtocol) ReadI16() (int16, error)

func (*SimpleJSONProtocol) ReadI32

func (p *SimpleJSONProtocol) ReadI32() (int32, error)

func (*SimpleJSONProtocol) ReadI64

func (p *SimpleJSONProtocol) ReadI64() (int64, error)

func (*SimpleJSONProtocol) ReadListBegin

func (p *SimpleJSONProtocol) ReadListBegin() (elemType Type, size int, e error)

func (*SimpleJSONProtocol) ReadListEnd

func (p *SimpleJSONProtocol) ReadListEnd() error

func (*SimpleJSONProtocol) ReadMapBegin

func (p *SimpleJSONProtocol) ReadMapBegin() (keyType Type, valueType Type, size int, e error)

func (*SimpleJSONProtocol) ReadMapEnd

func (p *SimpleJSONProtocol) ReadMapEnd() error

func (*SimpleJSONProtocol) ReadMessageBegin

func (p *SimpleJSONProtocol) ReadMessageBegin() (name string, typeId MessageType, seqId int32, err error)

Reading methods.

func (*SimpleJSONProtocol) ReadMessageEnd

func (p *SimpleJSONProtocol) ReadMessageEnd() error

func (*SimpleJSONProtocol) ReadSetBegin

func (p *SimpleJSONProtocol) ReadSetBegin() (elemType Type, size int, e error)

func (*SimpleJSONProtocol) ReadSetEnd

func (p *SimpleJSONProtocol) ReadSetEnd() error

func (*SimpleJSONProtocol) ReadString

func (p *SimpleJSONProtocol) ReadString() (string, error)

func (*SimpleJSONProtocol) ReadStructBegin

func (p *SimpleJSONProtocol) ReadStructBegin() (name string, err error)

func (*SimpleJSONProtocol) ReadStructEnd

func (p *SimpleJSONProtocol) ReadStructEnd() error

func (*SimpleJSONProtocol) Skip

func (p *SimpleJSONProtocol) Skip(fieldType Type) (err error)

func (*SimpleJSONProtocol) Transport

func (p *SimpleJSONProtocol) Transport() Transport

func (*SimpleJSONProtocol) WriteBinary

func (p *SimpleJSONProtocol) WriteBinary(v []byte) error

func (*SimpleJSONProtocol) WriteBool

func (p *SimpleJSONProtocol) WriteBool(b bool) error

func (*SimpleJSONProtocol) WriteByte

func (p *SimpleJSONProtocol) WriteByte(b byte) error

func (*SimpleJSONProtocol) WriteDouble

func (p *SimpleJSONProtocol) WriteDouble(v float64) error

func (*SimpleJSONProtocol) WriteFieldBegin

func (p *SimpleJSONProtocol) WriteFieldBegin(name string, typeId Type, id int16) error

func (*SimpleJSONProtocol) WriteFieldEnd

func (p *SimpleJSONProtocol) WriteFieldEnd() error

func (*SimpleJSONProtocol) WriteFieldStop

func (p *SimpleJSONProtocol) WriteFieldStop() error

func (*SimpleJSONProtocol) WriteFloat

func (p *SimpleJSONProtocol) WriteFloat(v float32) error

func (*SimpleJSONProtocol) WriteI16

func (p *SimpleJSONProtocol) WriteI16(v int16) error

func (*SimpleJSONProtocol) WriteI32

func (p *SimpleJSONProtocol) WriteI32(v int32) error

func (*SimpleJSONProtocol) WriteI64

func (p *SimpleJSONProtocol) WriteI64(v int64) error

func (*SimpleJSONProtocol) WriteListBegin

func (p *SimpleJSONProtocol) WriteListBegin(elemType Type, size int) error

func (*SimpleJSONProtocol) WriteListEnd

func (p *SimpleJSONProtocol) WriteListEnd() error

func (*SimpleJSONProtocol) WriteMapBegin

func (p *SimpleJSONProtocol) WriteMapBegin(keyType Type, valueType Type, size int) error

func (*SimpleJSONProtocol) WriteMapEnd

func (p *SimpleJSONProtocol) WriteMapEnd() error

func (*SimpleJSONProtocol) WriteMessageBegin

func (p *SimpleJSONProtocol) WriteMessageBegin(name string, typeId MessageType, seqId int32) error

func (*SimpleJSONProtocol) WriteMessageEnd

func (p *SimpleJSONProtocol) WriteMessageEnd() error

func (*SimpleJSONProtocol) WriteSetBegin

func (p *SimpleJSONProtocol) WriteSetBegin(elemType Type, size int) error

func (*SimpleJSONProtocol) WriteSetEnd

func (p *SimpleJSONProtocol) WriteSetEnd() error

func (*SimpleJSONProtocol) WriteString

func (p *SimpleJSONProtocol) WriteString(v string) error

func (*SimpleJSONProtocol) WriteStructBegin

func (p *SimpleJSONProtocol) WriteStructBegin(name string) error

func (*SimpleJSONProtocol) WriteStructEnd

func (p *SimpleJSONProtocol) WriteStructEnd() error

type SimpleJSONProtocolFactory

type SimpleJSONProtocolFactory struct{}

Factory

func NewSimpleJSONProtocolFactory

func NewSimpleJSONProtocolFactory() *SimpleJSONProtocolFactory

func (*SimpleJSONProtocolFactory) GetProtocol

func (p *SimpleJSONProtocolFactory) GetProtocol(trans Transport) Protocol

type SimpleServer

type SimpleServer struct {
	*ServerOptions
	// contains filtered or unexported fields
}

SimpleServer is a functional but unoptimized server that is easy to understand. In its accept loop, it performs an accept on an underlying socket, wraps the socket in the ServerTransport, and then spins up a gofunc to process requests.

There is one gofunc per active connection that handles all requests on the connection. multiple simultaneous requests over a single connection are not supported, as the per-connection gofunc reads the request, processes it, and writes the response serially

func NewSimpleServer

func NewSimpleServer(processor Processor, serverTransport ServerTransport, options ...func(*ServerOptions)) *SimpleServer

NewSimpleServer create a new server

func NewSimpleServer2

func NewSimpleServer2(processor Processor, serverTransport ServerTransport) *SimpleServer

NewSimpleServer2 is deprecated, used NewSimpleServer instead

func NewSimpleServer4

func NewSimpleServer4(processor Processor, serverTransport ServerTransport, transportFactory TransportFactory, protocolFactory ProtocolFactory) *SimpleServer

NewSimpleServer4 is deprecated, used NewSimpleServer instead

func NewSimpleServer6

func NewSimpleServer6(processor Processor, serverTransport ServerTransport, inputTransportFactory TransportFactory, outputTransportFactory TransportFactory, inputProtocolFactory ProtocolFactory, outputProtocolFactory ProtocolFactory) *SimpleServer

NewSimpleServer6 is deprecated, used NewSimpleServer instead

func NewSimpleServerContext

func NewSimpleServerContext(processor ProcessorContext, serverTransport ServerTransport, options ...func(*ServerOptions)) *SimpleServer

NewSimpleServerContext creates a new server that supports contexts

func NewSimpleServerFactory

func NewSimpleServerFactory(processorFactory ProcessorFactory, serverTransport ServerTransport, options ...func(*ServerOptions)) *SimpleServer

NewSimpleServerFactory create a new server factory

func NewSimpleServerFactory2

func NewSimpleServerFactory2(processorFactory ProcessorFactory, serverTransport ServerTransport) *SimpleServer

NewSimpleServerFactory2 is deprecated, used NewSimpleServerFactory instead

func NewSimpleServerFactory4

func NewSimpleServerFactory4(processorFactory ProcessorFactory, serverTransport ServerTransport, transportFactory TransportFactory, protocolFactory ProtocolFactory) *SimpleServer

NewSimpleServerFactory4 is deprecated, used NewSimpleServerFactory instead

func NewSimpleServerFactory6

func NewSimpleServerFactory6(processorFactory ProcessorFactory, serverTransport ServerTransport, inputTransportFactory TransportFactory, outputTransportFactory TransportFactory, inputProtocolFactory ProtocolFactory, outputProtocolFactory ProtocolFactory) *SimpleServer

NewSimpleServerFactory6 is deprecated, used NewSimpleServerFactory instead

func NewSimpleServerFactoryContext

func NewSimpleServerFactoryContext(processorFactoryContext ProcessorFactoryContext, serverTransport ServerTransport, options ...func(*ServerOptions)) *SimpleServer

NewSimpleServerFactoryContext creates a new server factory that supports contexts.

func (*SimpleServer) AcceptLoop

func (p *SimpleServer) AcceptLoop() error

AcceptLoop runs the accept loop to handle requests

func (*SimpleServer) AcceptLoopContext

func (p *SimpleServer) AcceptLoopContext(ctx context.Context) error

AcceptLoopContext is an AcceptLoop that supports contexts. The context is decorated with ConnInfo and passed down to new clients.

func (*SimpleServer) InputProtocolFactory

func (p *SimpleServer) InputProtocolFactory() ProtocolFactory

InputProtocolFactory returns the input protocolfactory

func (*SimpleServer) InputTransportFactory

func (p *SimpleServer) InputTransportFactory() TransportFactory

InputTransportFactory returns the input transport factory

func (*SimpleServer) Listen

func (p *SimpleServer) Listen() error

Listen returns the server transport listener

func (*SimpleServer) OutputProtocolFactory

func (p *SimpleServer) OutputProtocolFactory() ProtocolFactory

OutputProtocolFactory returns the output protocol factory

func (*SimpleServer) OutputTransportFactory

func (p *SimpleServer) OutputTransportFactory() TransportFactory

OutputTransportFactory returns the output transport factory

func (*SimpleServer) ProcessorFactoryContext

func (p *SimpleServer) ProcessorFactoryContext() ProcessorFactoryContext

ProcessorFactoryContext returns the processor factory that supports contexts

func (*SimpleServer) Serve

func (p *SimpleServer) Serve() error

Serve starts listening on the transport and accepting new connections and blocks until Stop is called or an error occurs.

func (*SimpleServer) ServeContext

func (p *SimpleServer) ServeContext(ctx context.Context) error

ServeContext behaves like Serve but supports cancellation via context.

func (*SimpleServer) ServerTransport

func (p *SimpleServer) ServerTransport() ServerTransport

ServerTransport returns the server transport

func (*SimpleServer) Stop

func (p *SimpleServer) Stop() error

Stop stops the server

type Socket

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

func NewSocket

func NewSocket(options ...SocketOption) (*Socket, error)

NewSocket creates a net.Conn-backed Transport, given a host and port, or an existing connection.

trans, err := thrift.NewSocket(thrift.SocketAddr("localhost:9090"))

func (*Socket) Addr

func (p *Socket) Addr() net.Addr

Returns the remote address of the socket.

func (*Socket) Close

func (p *Socket) Close() error

Closes the socket.

func (*Socket) Conn

func (p *Socket) Conn() net.Conn

Retrieve the underlying net.Conn

func (*Socket) Flush

func (p *Socket) Flush() error

func (*Socket) Interrupt

func (p *Socket) Interrupt() error

func (*Socket) IsOpen

func (p *Socket) IsOpen() bool

Returns true if the connection is open

func (*Socket) Open

func (p *Socket) Open() error

Connects the socket, creating a new socket object if necessary.

func (*Socket) Read

func (p *Socket) Read(buf []byte) (int, error)

func (*Socket) RemainingBytes

func (p *Socket) RemainingBytes() (num_bytes uint64)

func (*Socket) SetTimeout

func (p *Socket) SetTimeout(timeout time.Duration) error

Sets the socket timeout

func (*Socket) Write

func (p *Socket) Write(buf []byte) (int, error)

type SocketOption

type SocketOption func(*Socket) error

SocketOption is the type used to set options on the socket

func SocketAddr

func SocketAddr(hostPort string) SocketOption

SocketAddr sets the socket address

func SocketConn

func SocketConn(conn net.Conn) SocketOption

SocketConn sets the socket connection

func SocketTimeout

func SocketTimeout(timeout time.Duration) SocketOption

SocketTimeout sets the timeout

type StreamTransport

type StreamTransport struct {
	io.Reader
	io.Writer
	// contains filtered or unexported fields
}

StreamTransport is a Transport made of an io.Reader and/or an io.Writer

func NewStreamTransport

func NewStreamTransport(r io.Reader, w io.Writer) *StreamTransport

func NewStreamTransportLimitedR

func NewStreamTransportLimitedR(r io.Reader, n int) *StreamTransport

func NewStreamTransportR

func NewStreamTransportR(r io.Reader) *StreamTransport

func NewStreamTransportRW

func NewStreamTransportRW(rw io.ReadWriter) *StreamTransport

func NewStreamTransportW

func NewStreamTransportW(w io.Writer) *StreamTransport

func (*StreamTransport) Close

func (p *StreamTransport) Close() error

Closes both the input and output streams.

func (*StreamTransport) Flush

func (p *StreamTransport) Flush() error

Flushes the underlying output stream if not null.

func (*StreamTransport) IsOpen

func (p *StreamTransport) IsOpen() bool

func (*StreamTransport) Open

func (p *StreamTransport) Open() error

implicitly opened on creation, can't be reopened once closed

func (*StreamTransport) Read

func (p *StreamTransport) Read(c []byte) (n int, err error)

func (*StreamTransport) ReadByte

func (p *StreamTransport) ReadByte() (c byte, err error)

func (*StreamTransport) RemainingBytes

func (p *StreamTransport) RemainingBytes() (num_bytes uint64)

func (*StreamTransport) Write

func (p *StreamTransport) Write(c []byte) (n int, err error)

func (*StreamTransport) WriteByte

func (p *StreamTransport) WriteByte(c byte) (err error)

func (*StreamTransport) WriteString

func (p *StreamTransport) WriteString(s string) (n int, err error)

type StreamTransportFactory

type StreamTransportFactory struct {
	Reader io.Reader
	Writer io.Writer
	// contains filtered or unexported fields
}

func NewStreamTransportFactory

func NewStreamTransportFactory(reader io.Reader, writer io.Writer, isReadWriter bool) *StreamTransportFactory

func (*StreamTransportFactory) GetTransport

func (p *StreamTransportFactory) GetTransport(trans Transport) Transport

type Struct

type Struct interface {
	Write(p Protocol) error
	Read(p Protocol) error
}

Struct is the interface used to encapsulate a message that can be read and written to a protocol

type TransformID

type TransformID uint32

TransformID Numerical ID of transform function

const (
	// TransformNone Default null transform
	TransformNone TransformID = 0
	// TransformZlib Apply zlib compression
	TransformZlib TransformID = 1
	// TransformHMAC Deprecated and no longer supported
	TransformHMAC TransformID = 2
	// TransformSnappy Apply snappy compression
	TransformSnappy TransformID = 3
	// TransformQLZ Deprecated and no longer supported
	TransformQLZ TransformID = 4
	// TransformZstd Apply zstd compression
	TransformZstd TransformID = 5
)

func (TransformID) String

func (c TransformID) String() string

func (TransformID) Untransformer

func (c TransformID) Untransformer() (func(byteReader) (byteReader, error), error)

Untransformer will find a transform function to wrap a reader with to transformed the data.

type Transport

type Transport interface {
	io.ReadWriteCloser
	Flusher
	ReadSizeProvider

	// Opens the transport for communication
	Open() error

	// Returns true if the transport is open
	IsOpen() bool
}

Transport is an encapsulation of the I/O layer

func NewHTTPClient

func NewHTTPClient(urlstr string) (Transport, error)

func NewHTTPClientWithOptions

func NewHTTPClientWithOptions(urlstr string, options HTTPClientOptions) (Transport, error)

func NewHTTPPostClient

func NewHTTPPostClient(urlstr string) (Transport, error)

func NewHTTPPostClientWithOptions

func NewHTTPPostClientWithOptions(urlstr string, options HTTPClientOptions) (Transport, error)

type TransportException

type TransportException interface {
	Exception
	TypeID() int
	Err() error
}

TransportException is the interface for transport exceptions

func NewTransportException

func NewTransportException(t int, e string) TransportException

NewTransportException creates a new TransportException

func NewTransportExceptionFromError

func NewTransportExceptionFromError(e error) TransportException

NewTransportExceptionFromError creates a TransportException from an error

type TransportFactory

type TransportFactory interface {
	GetTransport(trans Transport) Transport
}

TransportFactory is used to create wrapped instance of Transports. This is used primarily in servers, which get Transports from a ServerTransport and then may want to mutate them (i.e. create a BufferedTransport from the underlying base transport)

func NewFramedTransportFactory

func NewFramedTransportFactory(factory TransportFactory) TransportFactory

func NewFramedTransportFactoryMaxLength

func NewFramedTransportFactoryMaxLength(factory TransportFactory, maxLength uint32) TransportFactory

func NewHeaderTransportFactory

func NewHeaderTransportFactory(factory TransportFactory) TransportFactory

func NewTransportFactory

func NewTransportFactory() TransportFactory

NewTransportFactory returns a new TransportFactory

type Type

type Type byte

Type constants in the Thrift protocol

func (Type) String

func (p Type) String() string

type WritableException

type WritableException interface {
	WritableStruct
	Exception
}

WritableException is an interface used to encapsulate an exception that can be written to a protocol

type WritableResult

type WritableResult interface {
	WritableStruct
	Exception() WritableException
}

WritableResult is an interface used to encapsulate a result struct that can be written to a protocol

type WritableStruct

type WritableStruct interface {
	Write(p Protocol) error
}

WritableStruct is an interface used to encapsulate a message that can be written to a protocol

type ZlibTransport

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

ZlibTransport is a Transport implementation that makes use of zlib compression.

func NewZlibTransport

func NewZlibTransport(trans Transport, level int) (*ZlibTransport, error)

NewZlibTransport constructs a new instance of ZlibTransport

func (*ZlibTransport) Close

func (z *ZlibTransport) Close() error

Close closes the reader and writer (flushing any unwritten data) and closes the underlying transport.

func (*ZlibTransport) Flush

func (z *ZlibTransport) Flush() error

Flush flushes the writer and its underlying transport.

func (*ZlibTransport) IsOpen

func (z *ZlibTransport) IsOpen() bool

IsOpen returns true if the transport is open

func (*ZlibTransport) Open

func (z *ZlibTransport) Open() error

Open opens the transport for communication

func (*ZlibTransport) Read

func (z *ZlibTransport) Read(p []byte) (int, error)

func (*ZlibTransport) RemainingBytes

func (z *ZlibTransport) RemainingBytes() uint64

func (*ZlibTransport) Write

func (z *ZlibTransport) Write(p []byte) (int, error)

type ZlibTransportFactory

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

ZlibTransportFactory is a factory for ZlibTransport instances

func NewZlibTransportFactory

func NewZlibTransportFactory(level int) *ZlibTransportFactory

NewZlibTransportFactory constructs a new instance of NewZlibTransportFactory

func (*ZlibTransportFactory) GetTransport

func (p *ZlibTransportFactory) GetTransport(trans Transport) Transport

GetTransport constructs a new instance of NewZlibTransport

Jump to

Keyboard shortcuts

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