thrift

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: Apache-2.0, BSD-3-Clause Imports: 28 Imported by: 6,923

Documentation

Index

Examples

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
	INVALID_TRANSFORM              = 8
	INVALID_PROTOCOL               = 9
	UNSUPPORTED_CLIENT_TYPE        = 10
	VALIDATION_FAILED              = 11
)
View Source
const (
	COMPACT_PROTOCOL_ID       = 0x082
	COMPACT_VERSION           = 1
	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_UUID          = 0x0D
)
View Source
const (
	DEFAULT_MAX_MESSAGE_SIZE = 100 * 1024 * 1024
	DEFAULT_MAX_FRAME_SIZE   = 16384000

	DEFAULT_TBINARY_STRICT_READ  = false
	DEFAULT_TBINARY_STRICT_WRITE = true

	DEFAULT_CONNECT_TIMEOUT = 0
	DEFAULT_SOCKET_TIMEOUT  = 0
)

Default TConfiguration values.

View Source
const (
	THeaderHeaderMagic  uint32 = 0x0fff0000
	THeaderHeaderMask   uint32 = 0xffff0000
	THeaderFlagsMask    uint32 = 0x0000ffff
	THeaderMaxFrameSize uint32 = 0x3fffffff
)

Constants defined in THeader format: https://github.com/apache/thrift/blob/master/doc/specs/HeaderFormat.md

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
)
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
	UUID   = 16
)
View Source
const DEFAULT_MAX_LENGTH = 16384000

Deprecated: Use DEFAULT_MAX_FRAME_SIZE instead.

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
)

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 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 THttpClientOptions.

View Source
var ErrAbandonRequest = abandonRequestError{}

ErrAbandonRequest is a special error that server handler implementations can return to indicate that the request has been abandoned.

TSimpleServer and compiler generated Process functions will check for this error, and close the client connection instead of trying to write the error back to the client.

It shall only be used when the server handler implementation know that the client already abandoned the request (by checking that the passed in context is already canceled, for example).

It also implements the interface defined by errors.Unwrap and always unwrap to context.Canceled error.

View Source
var ServerConnectivityCheckInterval = time.Millisecond * 5

ServerConnectivityCheckInterval defines the ticker interval used by connectivity check in thrift compiled TProcessorFunc implementations.

It's defined as a variable instead of constant, so that thrift server implementations can change its value to control the behavior.

If it's changed to <=0, the feature will be disabled.

View Source
var ServerStopTimeout = time.Duration(0)

ServerStopTimeout defines max stop wait duration used by server stop to avoid hanging too long to wait for all client connections to be closed gracefully.

It's defined as a variable instead of constant, so that thrift server implementations can change its value to control the behavior.

If it's set to <=0, the feature will be disabled(by default), and the server will wait for for all the client connections to be closed gracefully.

Functions

func AddReadTHeaderToContext added in v0.13.0

func AddReadTHeaderToContext(ctx context.Context, headers THeaderMap) context.Context

AddReadTHeaderToContext adds the whole THeader headers into context.

func BoolPtr

func BoolPtr(v bool) *bool

func ByteSlicePtr

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

func ExtractExceptionFromResult added in v0.17.0

func ExtractExceptionFromResult(result TStruct) error

ExtractExceptionFromResult extracts exceptions defined in thrift IDL from result TStruct used in TClient.Call.

For a endpoint defined in thrift IDL like this:

service MyService {
  FooResponse foo(1: FooRequest request) throws (
    1: Exception1 error1,
    2: Exception2 error2,
  )
}

The thrift compiler generated go code for the result TStruct would be like:

type MyServiceFooResult struct {
  Success *FooResponse `thrift:"success,0" db:"success" json:"success,omitempty"`
  Error1 *Exception1 `thrift:"error1,1" db:"error1" json:"error1,omitempty"`
  Error2 *Exception2 `thrift:"error2,2" db:"error2" json:"error2,omitempty"`
}

And this function extracts the first non-nil exception out of *MyServiceFooResult.

func Float32Ptr

func Float32Ptr(v float32) *float32

func Float64Ptr

func Float64Ptr(v float64) *float64

func GetHeader added in v0.13.0

func GetHeader(ctx context.Context, key string) (value string, ok bool)

GetHeader returns a value of the given header from the context.

func GetReadHeaderList added in v0.13.0

func GetReadHeaderList(ctx context.Context) []string

GetReadHeaderList returns the key list of read THeaders from the context.

func GetWriteHeaderList added in v0.13.0

func GetWriteHeaderList(ctx context.Context) []string

GetWriteHeaderList returns the key list of THeaders to write from the context.

func Int16Ptr added in v0.13.0

func Int16Ptr(v int16) *int16

func Int32Ptr

func Int32Ptr(v int32) *int32

func Int64Ptr

func Int64Ptr(v int64) *int64

func Int8Ptr added in v0.13.0

func Int8Ptr(v int8) *int8

func IntPtr

func IntPtr(v int) *int

func Must added in v0.18.0

func Must[T any](v T, err error) T

Must is a sugar to be used in places that error handling is impossible (for example, global variable declarations) and also errors are not in general expected.

This is an example to use Must with ParseTuuid to declare a global special uuid:

var NameSpaceDNSUUID = thrift.Must(thrift.ParseTuuid("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))

func NewStoredMessageProtocol

func NewStoredMessageProtocol(protocol TProtocol, name string, typeId TMessageType, seqid int32) *storedMessageProtocol

func NewThriftHandlerFunc

func NewThriftHandlerFunc(processor TProcessor,
	inPfactory, outPfactory TProtocolFactory) func(w http.ResponseWriter, r *http.Request)

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

func NewTransformWriter added in v0.13.0

func NewTransformWriter(baseWriter io.Writer, transforms []THeaderTransformID) (io.WriteCloser, error)

NewTransformWriter creates a new TransformWriter with base writer and transforms.

func NopLogger deprecated added in v0.14.0

func NopLogger(msg string)

NopLogger is a Logger implementation that does nothing.

Deprecated: This is no longer used by any thrift go library code, will be removed in the future version.

func Pointer added in v0.17.0

func Pointer[T any](v T) *T

Pointer is the generic (type parameter) version of the helper function that converts types to pointer types.

func PrependError

func PrependError(prepend string, err error) error

Prepends additional information to an error without losing the Thrift exception interface

func PropagateTConfiguration added in v0.14.0

func PropagateTConfiguration(impl interface{}, cfg *TConfiguration)

PropagateTConfiguration propagates cfg to impl if impl implements TConfigurationSetter and cfg is non-nil, otherwise it does nothing.

NOTE: nil cfg is not propagated. If you want to propagate a TConfiguration with everything being default value, use &TConfiguration{} explicitly instead.

func SetHeader added in v0.13.0

func SetHeader(ctx context.Context, key, value string) context.Context

SetHeader sets a header in the context.

func SetReadHeaderList added in v0.13.0

func SetReadHeaderList(ctx context.Context, keys []string) context.Context

SetReadHeaderList sets the key list of read THeaders in the context.

func SetResponseHelper added in v0.14.0

func SetResponseHelper(ctx context.Context, helper TResponseHelper) context.Context

SetResponseHelper injects TResponseHelper into the context object.

func SetWriteHeaderList added in v0.13.0

func SetWriteHeaderList(ctx context.Context, keys []string) context.Context

SetWriteHeaderList sets the key list of THeaders to write in the context.

func Skip

func Skip(ctx context.Context, self TProtocol, fieldType TType, maxDepth int) (err error)

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

func SkipDefaultDepth

func SkipDefaultDepth(ctx context.Context, prot TProtocol, typeId TType) (err error)

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

func StringPtr

func StringPtr(v string) *string

func Uint32Ptr

func Uint32Ptr(v uint32) *uint32

func Uint64Ptr

func Uint64Ptr(v uint64) *uint64

func UnsetHeader added in v0.14.0

func UnsetHeader(ctx context.Context, key string) context.Context

UnsetHeader unsets a previously set header in the context.

Types

type ClientMiddleware added in v0.14.0

type ClientMiddleware func(TClient) TClient

ClientMiddleware can be passed to WrapClient in order to wrap TClient calls with custom middleware.

Example

This example demonstrates how to define and use a simple logging middleware to your thrift client.

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package main

import (
	"context"
	"log"
)

// BEGIN THRIFT GENERATED CODE SECTION
//
// In real code this section should be from thrift generated code instead,
// but for this example we just define some placeholders here.

type MyEndpointRequest struct{}

type MyEndpointResponse struct{}

type MyService interface {
	MyEndpoint(ctx context.Context, req *MyEndpointRequest) (*MyEndpointResponse, error)
}

func NewMyServiceClient(_ TClient) MyService {
	// In real code this certainly won't return nil.
	return nil
}

// END THRIFT GENERATED CODE SECTION

func simpleClientLoggingMiddleware(next TClient) TClient {
	return WrappedTClient{
		Wrapped: func(ctx context.Context, method string, args, result TStruct) (ResponseMeta, error) {
			log.Printf("Before: %q", method)
			log.Printf("Args: %#v", args)
			headers, err := next.Call(ctx, method, args, result)
			log.Printf("After: %q", method)
			log.Printf("Result: %#v", result)
			if err != nil {
				log.Printf("Error: %v", err)
			}
			return headers, err
		},
	}
}

// This example demonstrates how to define and use a simple logging middleware
// to your thrift client.
func main() {
	var (
		trans        TTransport
		protoFactory TProtocolFactory
	)
	var client TClient
	client = NewTStandardClient(
		protoFactory.GetProtocol(trans),
		protoFactory.GetProtocol(trans),
	)
	client = WrapClient(client, simpleClientLoggingMiddleware)
	myServiceClient := NewMyServiceClient(client)
	myServiceClient.MyEndpoint(context.Background(), &MyEndpointRequest{})
}
Output:

type ContextFlusher

type ContextFlusher interface {
	Flush(ctx context.Context) (err error)
}

type Flusher

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

type Logger deprecated added in v0.14.0

type Logger func(msg string)

Logger is a simple wrapper of a logging function.

In reality the users might actually use different logging libraries, and they are not always compatible with each other.

Logger is meant to be a simple common ground that it's easy to wrap whatever logging library they use into.

See https://issues.apache.org/jira/browse/THRIFT-4985 for the design discussion behind it.

Deprecated: This is no longer used by any thrift go library code, will be removed in the future version.

func StdLogger deprecated added in v0.14.0

func StdLogger(logger *log.Logger) Logger

StdLogger wraps stdlib log package into a Logger.

If logger passed in is nil, it will fallback to use stderr and default flags.

Deprecated: This is no longer used by any thrift go library code, will be removed in the future version.

func TestLogger deprecated added in v0.14.0

func TestLogger(tb testing.TB) Logger

TestLogger is a Logger implementation can be used in test codes.

It fails the test when being called.

Deprecated: This is no longer used by any thrift go library code, will be removed in the future version.

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
	NEGATIVE_INFINITY Numeric
	NAN               Numeric
	ZERO              Numeric
	NUMERIC_NULL      Numeric
)

func NewNullNumeric

func NewNullNumeric() Numeric

func NewNumericFromDouble

func NewNumericFromDouble(dValue float64) 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 ProcessorMiddleware added in v0.14.0

type ProcessorMiddleware func(name string, next TProcessorFunction) TProcessorFunction

ProcessorMiddleware is a function that can be passed to WrapProcessor to wrap the TProcessorFunctions for that TProcessor.

Middlewares are passed in the name of the function as set in the processor map of the TProcessor.

Example

This example demonstrates how to define and use a simple logging middleware to your thrift server/processor.

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package main

import (
	"context"
	"log"
)

func SimpleProcessorLoggingMiddleware(name string, next TProcessorFunction) TProcessorFunction {
	return WrappedTProcessorFunction{
		Wrapped: func(ctx context.Context, seqId int32, in, out TProtocol) (bool, TException) {
			log.Printf("Before: %q", name)
			success, err := next.Process(ctx, seqId, in, out)
			log.Printf("After: %q", name)
			log.Printf("Success: %v", success)
			if err != nil {
				log.Printf("Error: %v", err)
			}
			return success, err
		},
	}
}

// This example demonstrates how to define and use a simple logging middleware
// to your thrift server/processor.
func main() {
	var (
		processor    TProcessor
		trans        TServerTransport
		transFactory TTransportFactory
		protoFactory TProtocolFactory
	)
	processor = WrapProcessor(processor, SimpleProcessorLoggingMiddleware)
	server := NewTSimpleServer4(processor, trans, transFactory, protoFactory)
	log.Fatal(server.Serve())
}
Output:

type ReadSizeProvider

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

type ResponseMeta added in v0.14.0

type ResponseMeta struct {
	// The headers in the response, if any.
	// If the underlying transport/protocol is not THeader, this will always be nil.
	Headers THeaderMap
}

ResponseMeta represents the metadata attached to the response.

type RichTransport

type RichTransport struct {
	TTransport
}

func NewTRichTransport

func NewTRichTransport(trans TTransport) *RichTransport

Wraps Transport to provide TRichTransport interface

func (*RichTransport) ReadByte

func (r *RichTransport) ReadByte() (c byte, err error)

func (*RichTransport) RemainingBytes

func (r *RichTransport) RemainingBytes() (num_bytes uint64)

func (*RichTransport) WriteByte

func (r *RichTransport) WriteByte(c byte) error

func (*RichTransport) WriteString

func (r *RichTransport) WriteString(s string) (n int, err error)

type SlogTStructWrapper added in v0.20.0

type SlogTStructWrapper struct {
	Type  string  `json:"type"`
	Value TStruct `json:"value"`
}

SlogTStructWrapper is a wrapper used by the compiler to wrap TStruct and TException to be better logged by slog.

func (SlogTStructWrapper) MarshalJSON added in v0.20.0

func (w SlogTStructWrapper) MarshalJSON() ([]byte, error)

func (SlogTStructWrapper) String added in v0.20.0

func (w SlogTStructWrapper) String() string

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 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(ctx context.Context) 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) SetTConfiguration added in v0.14.0

func (p *StreamTransport) SetTConfiguration(conf *TConfiguration)

SetTConfiguration implements TConfigurationSetter for propagation.

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 TTransport) (TTransport, error)

type TApplicationException

type TApplicationException interface {
	TException
	TypeId() int32
	Read(ctx context.Context, iprot TProtocol) error
	Write(ctx context.Context, oprot TProtocol) error
}

Application level Thrift exception

func NewTApplicationException

func NewTApplicationException(type_ int32, message string) TApplicationException

func NewValidationException added in v0.18.0

func NewValidationException(type_ int32, check string, field string, message string) TApplicationException

type TBinaryProtocol

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

func NewTBinaryProtocol deprecated

func NewTBinaryProtocol(t TTransport, strictRead, strictWrite bool) *TBinaryProtocol

Deprecated: Use NewTBinaryProtocolConf instead.

func NewTBinaryProtocolConf added in v0.14.0

func NewTBinaryProtocolConf(t TTransport, conf *TConfiguration) *TBinaryProtocol

func NewTBinaryProtocolTransport deprecated

func NewTBinaryProtocolTransport(t TTransport) *TBinaryProtocol

Deprecated: Use NewTBinaryProtocolConf instead.

func (*TBinaryProtocol) Flush

func (p *TBinaryProtocol) Flush(ctx context.Context) (err error)

func (*TBinaryProtocol) ReadBinary

func (p *TBinaryProtocol) ReadBinary(ctx context.Context) ([]byte, error)

func (*TBinaryProtocol) ReadBool

func (p *TBinaryProtocol) ReadBool(ctx context.Context) (bool, error)

func (*TBinaryProtocol) ReadByte

func (p *TBinaryProtocol) ReadByte(ctx context.Context) (int8, error)

func (*TBinaryProtocol) ReadDouble

func (p *TBinaryProtocol) ReadDouble(ctx context.Context) (value float64, err error)

func (*TBinaryProtocol) ReadFieldBegin

func (p *TBinaryProtocol) ReadFieldBegin(ctx context.Context) (name string, typeId TType, seqId int16, err error)

func (*TBinaryProtocol) ReadFieldEnd

func (p *TBinaryProtocol) ReadFieldEnd(ctx context.Context) error

func (*TBinaryProtocol) ReadI16

func (p *TBinaryProtocol) ReadI16(ctx context.Context) (value int16, err error)

func (*TBinaryProtocol) ReadI32

func (p *TBinaryProtocol) ReadI32(ctx context.Context) (value int32, err error)

func (*TBinaryProtocol) ReadI64

func (p *TBinaryProtocol) ReadI64(ctx context.Context) (value int64, err error)

func (*TBinaryProtocol) ReadListBegin

func (p *TBinaryProtocol) ReadListBegin(ctx context.Context) (elemType TType, size int, err error)

func (*TBinaryProtocol) ReadListEnd

func (p *TBinaryProtocol) ReadListEnd(ctx context.Context) error

func (*TBinaryProtocol) ReadMapBegin

func (p *TBinaryProtocol) ReadMapBegin(ctx context.Context) (kType, vType TType, size int, err error)

func (*TBinaryProtocol) ReadMapEnd

func (p *TBinaryProtocol) ReadMapEnd(ctx context.Context) error

func (*TBinaryProtocol) ReadMessageBegin

func (p *TBinaryProtocol) ReadMessageBegin(ctx context.Context) (name string, typeId TMessageType, seqId int32, err error)

func (*TBinaryProtocol) ReadMessageEnd

func (p *TBinaryProtocol) ReadMessageEnd(ctx context.Context) error

func (*TBinaryProtocol) ReadSetBegin

func (p *TBinaryProtocol) ReadSetBegin(ctx context.Context) (elemType TType, size int, err error)

func (*TBinaryProtocol) ReadSetEnd

func (p *TBinaryProtocol) ReadSetEnd(ctx context.Context) error

func (*TBinaryProtocol) ReadString

func (p *TBinaryProtocol) ReadString(ctx context.Context) (value string, err error)

func (*TBinaryProtocol) ReadStructBegin

func (p *TBinaryProtocol) ReadStructBegin(ctx context.Context) (name string, err error)

func (*TBinaryProtocol) ReadStructEnd

func (p *TBinaryProtocol) ReadStructEnd(ctx context.Context) error

func (*TBinaryProtocol) ReadUUID added in v0.18.0

func (p *TBinaryProtocol) ReadUUID(ctx context.Context) (value Tuuid, err error)

func (*TBinaryProtocol) SetTConfiguration added in v0.14.0

func (p *TBinaryProtocol) SetTConfiguration(conf *TConfiguration)

func (*TBinaryProtocol) Skip

func (p *TBinaryProtocol) Skip(ctx context.Context, fieldType TType) (err error)

func (*TBinaryProtocol) Transport

func (p *TBinaryProtocol) Transport() TTransport

func (*TBinaryProtocol) WriteBinary

func (p *TBinaryProtocol) WriteBinary(ctx context.Context, value []byte) error

func (*TBinaryProtocol) WriteBool

func (p *TBinaryProtocol) WriteBool(ctx context.Context, value bool) error

func (*TBinaryProtocol) WriteByte

func (p *TBinaryProtocol) WriteByte(ctx context.Context, value int8) error

func (*TBinaryProtocol) WriteDouble

func (p *TBinaryProtocol) WriteDouble(ctx context.Context, value float64) error

func (*TBinaryProtocol) WriteFieldBegin

func (p *TBinaryProtocol) WriteFieldBegin(ctx context.Context, name string, typeId TType, id int16) error

func (*TBinaryProtocol) WriteFieldEnd

func (p *TBinaryProtocol) WriteFieldEnd(ctx context.Context) error

func (*TBinaryProtocol) WriteFieldStop

func (p *TBinaryProtocol) WriteFieldStop(ctx context.Context) error

func (*TBinaryProtocol) WriteI16

func (p *TBinaryProtocol) WriteI16(ctx context.Context, value int16) error

func (*TBinaryProtocol) WriteI32

func (p *TBinaryProtocol) WriteI32(ctx context.Context, value int32) error

func (*TBinaryProtocol) WriteI64

func (p *TBinaryProtocol) WriteI64(ctx context.Context, value int64) error

func (*TBinaryProtocol) WriteListBegin

func (p *TBinaryProtocol) WriteListBegin(ctx context.Context, elemType TType, size int) error

func (*TBinaryProtocol) WriteListEnd

func (p *TBinaryProtocol) WriteListEnd(ctx context.Context) error

func (*TBinaryProtocol) WriteMapBegin

func (p *TBinaryProtocol) WriteMapBegin(ctx context.Context, keyType TType, valueType TType, size int) error

func (*TBinaryProtocol) WriteMapEnd

func (p *TBinaryProtocol) WriteMapEnd(ctx context.Context) error

func (*TBinaryProtocol) WriteMessageBegin

func (p *TBinaryProtocol) WriteMessageBegin(ctx context.Context, name string, typeId TMessageType, seqId int32) error

func (*TBinaryProtocol) WriteMessageEnd

func (p *TBinaryProtocol) WriteMessageEnd(ctx context.Context) error

func (*TBinaryProtocol) WriteSetBegin

func (p *TBinaryProtocol) WriteSetBegin(ctx context.Context, elemType TType, size int) error

func (*TBinaryProtocol) WriteSetEnd

func (p *TBinaryProtocol) WriteSetEnd(ctx context.Context) error

func (*TBinaryProtocol) WriteString

func (p *TBinaryProtocol) WriteString(ctx context.Context, value string) error

func (*TBinaryProtocol) WriteStructBegin

func (p *TBinaryProtocol) WriteStructBegin(ctx context.Context, name string) error

func (*TBinaryProtocol) WriteStructEnd

func (p *TBinaryProtocol) WriteStructEnd(ctx context.Context) error

func (*TBinaryProtocol) WriteUUID added in v0.18.0

func (p *TBinaryProtocol) WriteUUID(ctx context.Context, value Tuuid) error

type TBinaryProtocolFactory

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

func NewTBinaryProtocolFactory deprecated

func NewTBinaryProtocolFactory(strictRead, strictWrite bool) *TBinaryProtocolFactory

Deprecated: Use NewTBinaryProtocolFactoryConf instead.

func NewTBinaryProtocolFactoryConf added in v0.14.0

func NewTBinaryProtocolFactoryConf(conf *TConfiguration) *TBinaryProtocolFactory

func NewTBinaryProtocolFactoryDefault deprecated

func NewTBinaryProtocolFactoryDefault() *TBinaryProtocolFactory

Deprecated: Use NewTBinaryProtocolFactoryConf instead.

func (*TBinaryProtocolFactory) GetProtocol

func (p *TBinaryProtocolFactory) GetProtocol(t TTransport) TProtocol

func (*TBinaryProtocolFactory) SetTConfiguration added in v0.14.0

func (p *TBinaryProtocolFactory) SetTConfiguration(conf *TConfiguration)

type TBufferedTransport

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

func NewTBufferedTransport

func NewTBufferedTransport(trans TTransport, bufferSize int) *TBufferedTransport

func (*TBufferedTransport) Close

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

func (*TBufferedTransport) Flush

func (p *TBufferedTransport) Flush(ctx context.Context) error

func (*TBufferedTransport) IsOpen

func (p *TBufferedTransport) IsOpen() bool

func (*TBufferedTransport) Open

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

func (*TBufferedTransport) Read

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

func (*TBufferedTransport) RemainingBytes

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

func (*TBufferedTransport) SetTConfiguration added in v0.14.0

func (p *TBufferedTransport) SetTConfiguration(conf *TConfiguration)

SetTConfiguration implements TConfigurationSetter for propagation.

func (*TBufferedTransport) Write

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

type TBufferedTransportFactory

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

func NewTBufferedTransportFactory

func NewTBufferedTransportFactory(bufferSize int) *TBufferedTransportFactory

func (*TBufferedTransportFactory) GetTransport

func (p *TBufferedTransportFactory) GetTransport(trans TTransport) (TTransport, error)

type TClient

type TClient interface {
	Call(ctx context.Context, method string, args, result TStruct) (ResponseMeta, error)
}

func ExtractIDLExceptionClientMiddleware added in v0.17.0

func ExtractIDLExceptionClientMiddleware(next TClient) TClient

ExtractIDLExceptionClientMiddleware is a ClientMiddleware implementation that extracts exceptions defined in thrift IDL into the error return of TClient.Call. It uses ExtractExceptionFromResult under the hood.

By default if a client call gets an exception defined in the thrift IDL, for example:

service MyService {
  FooResponse foo(1: FooRequest request) throws (
    1: Exception1 error1,
    2: Exception2 error2,
  )
}

Exception1 or Exception2 will not be in the err return of TClient.Call, but in the result TStruct instead, and there's no easy access to them. If you have a ClientMiddleware that would need to access them, you can add this middleware into your client middleware chain, *after* your other middlewares need them, then your other middlewares will have access to those exceptions from the err return.

Alternatively you can also just use ExtractExceptionFromResult in your client middleware directly to access those exceptions.

func WrapClient added in v0.14.0

func WrapClient(client TClient, middlewares ...ClientMiddleware) TClient

WrapClient wraps the given TClient in the given middlewares.

Middlewares will be called in the order that they are defined:

  1. Middlewares[0]
  2. Middlewares[1] ... N. Middlewares[n]

type TCompactProtocol

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

func NewTCompactProtocol deprecated

func NewTCompactProtocol(trans TTransport) *TCompactProtocol

Deprecated: Use NewTCompactProtocolConf instead.

func NewTCompactProtocolConf added in v0.14.0

func NewTCompactProtocolConf(trans TTransport, conf *TConfiguration) *TCompactProtocol

func (*TCompactProtocol) Flush

func (p *TCompactProtocol) Flush(ctx context.Context) (err error)

func (*TCompactProtocol) ReadBinary

func (p *TCompactProtocol) ReadBinary(ctx context.Context) (value []byte, err error)

Read a []byte from the wire.

func (*TCompactProtocol) ReadBool

func (p *TCompactProtocol) ReadBool(ctx context.Context) (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 (*TCompactProtocol) ReadByte

func (p *TCompactProtocol) ReadByte(ctx context.Context) (int8, error)

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

func (*TCompactProtocol) ReadDouble

func (p *TCompactProtocol) ReadDouble(ctx context.Context) (value float64, err error)

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

func (*TCompactProtocol) ReadFieldBegin

func (p *TCompactProtocol) ReadFieldBegin(ctx context.Context) (name string, typeId TType, id int16, err error)

Read a field header off the wire.

func (*TCompactProtocol) ReadFieldEnd

func (p *TCompactProtocol) ReadFieldEnd(ctx context.Context) error

func (*TCompactProtocol) ReadI16

func (p *TCompactProtocol) ReadI16(ctx context.Context) (value int16, err error)

Read an i16 from the wire as a zigzag varint.

func (*TCompactProtocol) ReadI32

func (p *TCompactProtocol) ReadI32(ctx context.Context) (value int32, err error)

Read an i32 from the wire as a zigzag varint.

func (*TCompactProtocol) ReadI64

func (p *TCompactProtocol) ReadI64(ctx context.Context) (value int64, err error)

Read an i64 from the wire as a zigzag varint.

func (*TCompactProtocol) ReadListBegin

func (p *TCompactProtocol) ReadListBegin(ctx context.Context) (elemType TType, 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 (*TCompactProtocol) ReadListEnd

func (p *TCompactProtocol) ReadListEnd(ctx context.Context) error

func (*TCompactProtocol) ReadMapBegin

func (p *TCompactProtocol) ReadMapBegin(ctx context.Context) (keyType TType, valueType TType, 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 TMaps without the "correct" types.

func (*TCompactProtocol) ReadMapEnd

func (p *TCompactProtocol) ReadMapEnd(ctx context.Context) error

func (*TCompactProtocol) ReadMessageBegin

func (p *TCompactProtocol) ReadMessageBegin(ctx context.Context) (name string, typeId TMessageType, seqId int32, err error)

Read a message header.

func (*TCompactProtocol) ReadMessageEnd

func (p *TCompactProtocol) ReadMessageEnd(ctx context.Context) error

func (*TCompactProtocol) ReadSetBegin

func (p *TCompactProtocol) ReadSetBegin(ctx context.Context) (elemType TType, 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 (*TCompactProtocol) ReadSetEnd

func (p *TCompactProtocol) ReadSetEnd(ctx context.Context) error

func (*TCompactProtocol) ReadString

func (p *TCompactProtocol) ReadString(ctx context.Context) (value string, err error)

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

func (*TCompactProtocol) ReadStructBegin

func (p *TCompactProtocol) ReadStructBegin(ctx context.Context) (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 (*TCompactProtocol) ReadStructEnd

func (p *TCompactProtocol) ReadStructEnd(ctx context.Context) error

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

func (*TCompactProtocol) ReadUUID added in v0.18.0

func (p *TCompactProtocol) ReadUUID(ctx context.Context) (value Tuuid, err error)

Read fixed 16 bytes as UUID.

func (*TCompactProtocol) SetTConfiguration added in v0.14.0

func (p *TCompactProtocol) SetTConfiguration(conf *TConfiguration)

func (*TCompactProtocol) Skip

func (p *TCompactProtocol) Skip(ctx context.Context, fieldType TType) (err error)

func (*TCompactProtocol) Transport

func (p *TCompactProtocol) Transport() TTransport

func (*TCompactProtocol) WriteBinary

func (p *TCompactProtocol) WriteBinary(ctx context.Context, bin []byte) error

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

func (*TCompactProtocol) WriteBool

func (p *TCompactProtocol) WriteBool(ctx context.Context, value bool) error

func (*TCompactProtocol) WriteByte

func (p *TCompactProtocol) WriteByte(ctx context.Context, value int8) error

Write a byte. Nothing to see here!

func (*TCompactProtocol) WriteDouble

func (p *TCompactProtocol) WriteDouble(ctx context.Context, value float64) error

Write a double to the wire as 8 bytes.

func (*TCompactProtocol) WriteFieldBegin

func (p *TCompactProtocol) WriteFieldBegin(ctx context.Context, name string, typeId TType, id int16) error

func (*TCompactProtocol) WriteFieldEnd

func (p *TCompactProtocol) WriteFieldEnd(ctx context.Context) error

func (*TCompactProtocol) WriteFieldStop

func (p *TCompactProtocol) WriteFieldStop(ctx context.Context) error

func (*TCompactProtocol) WriteI16

func (p *TCompactProtocol) WriteI16(ctx context.Context, value int16) error

Write an I16 as a zigzag varint.

func (*TCompactProtocol) WriteI32

func (p *TCompactProtocol) WriteI32(ctx context.Context, value int32) error

Write an i32 as a zigzag varint.

func (*TCompactProtocol) WriteI64

func (p *TCompactProtocol) WriteI64(ctx context.Context, value int64) error

Write an i64 as a zigzag varint.

func (*TCompactProtocol) WriteListBegin

func (p *TCompactProtocol) WriteListBegin(ctx context.Context, elemType TType, size int) error

Write a list header.

func (*TCompactProtocol) WriteListEnd

func (p *TCompactProtocol) WriteListEnd(ctx context.Context) error

func (*TCompactProtocol) WriteMapBegin

func (p *TCompactProtocol) WriteMapBegin(ctx context.Context, keyType TType, valueType TType, size int) error

func (*TCompactProtocol) WriteMapEnd

func (p *TCompactProtocol) WriteMapEnd(ctx context.Context) error

func (*TCompactProtocol) WriteMessageBegin

func (p *TCompactProtocol) WriteMessageBegin(ctx context.Context, name string, typeId TMessageType, 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 (*TCompactProtocol) WriteMessageEnd

func (p *TCompactProtocol) WriteMessageEnd(ctx context.Context) error

func (*TCompactProtocol) WriteSetBegin

func (p *TCompactProtocol) WriteSetBegin(ctx context.Context, elemType TType, size int) error

Write a set header.

func (*TCompactProtocol) WriteSetEnd

func (p *TCompactProtocol) WriteSetEnd(ctx context.Context) error

func (*TCompactProtocol) WriteString

func (p *TCompactProtocol) WriteString(ctx context.Context, value string) error

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

func (*TCompactProtocol) WriteStructBegin

func (p *TCompactProtocol) WriteStructBegin(ctx context.Context, 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 (*TCompactProtocol) WriteStructEnd

func (p *TCompactProtocol) WriteStructEnd(ctx context.Context) 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.

func (*TCompactProtocol) WriteUUID added in v0.18.0

func (p *TCompactProtocol) WriteUUID(ctx context.Context, value Tuuid) error

Write a Tuuid to the wire as 16 bytes.

type TCompactProtocolFactory

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

func NewTCompactProtocolFactory deprecated

func NewTCompactProtocolFactory() *TCompactProtocolFactory

Deprecated: Use NewTCompactProtocolFactoryConf instead.

func NewTCompactProtocolFactoryConf added in v0.14.0

func NewTCompactProtocolFactoryConf(conf *TConfiguration) *TCompactProtocolFactory

func (*TCompactProtocolFactory) GetProtocol

func (p *TCompactProtocolFactory) GetProtocol(trans TTransport) TProtocol

func (*TCompactProtocolFactory) SetTConfiguration added in v0.14.0

func (p *TCompactProtocolFactory) SetTConfiguration(conf *TConfiguration)

type TConfiguration added in v0.14.0

type TConfiguration struct {
	// If <= 0, DEFAULT_MAX_MESSAGE_SIZE will be used instead.
	MaxMessageSize int32

	// If <= 0, DEFAULT_MAX_FRAME_SIZE will be used instead.
	//
	// Also if MaxMessageSize < MaxFrameSize,
	// MaxMessageSize will be used instead.
	MaxFrameSize int32

	// Connect and socket timeouts to be used by TSocket and TSSLSocket.
	//
	// 0 means no timeout.
	//
	// If <0, DEFAULT_CONNECT_TIMEOUT and DEFAULT_SOCKET_TIMEOUT will be
	// used.
	ConnectTimeout time.Duration
	SocketTimeout  time.Duration

	// TLS config to be used by TSSLSocket.
	TLSConfig *tls.Config

	// Strict read/write configurations for TBinaryProtocol.
	//
	// BoolPtr helper function is available to use literal values.
	TBinaryStrictRead  *bool
	TBinaryStrictWrite *bool

	// The wrapped protocol id to be used in THeader transport/protocol.
	//
	// THeaderProtocolIDPtr and THeaderProtocolIDPtrMust helper functions
	// are provided to help filling this value.
	THeaderProtocolID *THeaderProtocolID
	// The write transforms to be applied to THeaderTransport.
	THeaderTransforms []THeaderTransformID
	// contains filtered or unexported fields
}

TConfiguration defines some configurations shared between TTransport, TProtocol, TTransportFactory, TProtocolFactory, and other implementations.

When constructing TConfiguration, you only need to specify the non-default fields. All zero values have sane default values.

Not all configurations defined are applicable to all implementations. Implementations are free to ignore the configurations not applicable to them.

All functions attached to this type are nil-safe.

See 1 for spec.

NOTE: When using TConfiguration, fill in all the configurations you want to set across the stack, not only the ones you want to set in the immediate TTransport/TProtocol.

For example, say you want to migrate this old code into using TConfiguration:

socket, err := thrift.NewTSocketTimeout("host:port", time.Second, time.Second)
transFactory := thrift.NewTFramedTransportFactoryMaxLength(
    thrift.NewTTransportFactory(),
    1024 * 1024 * 256,
)
protoFactory := thrift.NewTBinaryProtocolFactory(true, true)

This is the wrong way to do it because in the end the TConfiguration used by socket and transFactory will be overwritten by the one used by protoFactory because of TConfiguration propagation:

// bad example, DO NOT USE
socket := thrift.NewTSocketConf("host:port", &thrift.TConfiguration{
    ConnectTimeout: time.Second,
    SocketTimeout:  time.Second,
})
transFactory := thrift.NewTFramedTransportFactoryConf(
    thrift.NewTTransportFactory(),
    &thrift.TConfiguration{
        MaxFrameSize: 1024 * 1024 * 256,
    },
)
protoFactory := thrift.NewTBinaryProtocolFactoryConf(&thrift.TConfiguration{
    TBinaryStrictRead:  thrift.BoolPtr(true),
    TBinaryStrictWrite: thrift.BoolPtr(true),
})

This is the correct way to do it:

conf := &thrift.TConfiguration{
    ConnectTimeout: time.Second,
    SocketTimeout:  time.Second,

    MaxFrameSize: 1024 * 1024 * 256,

    TBinaryStrictRead:  thrift.BoolPtr(true),
    TBinaryStrictWrite: thrift.BoolPtr(true),
}
socket := thrift.NewTSocketConf("host:port", conf)
transFactory := thrift.NewTFramedTransportFactoryConf(thrift.NewTTransportFactory(), conf)
protoFactory := thrift.NewTBinaryProtocolFactoryConf(conf)

func (*TConfiguration) GetConnectTimeout added in v0.14.0

func (tc *TConfiguration) GetConnectTimeout() time.Duration

GetConnectTimeout returns the connect timeout should be used by TSocket and TSSLSocket.

It's nil-safe. If tc is nil, DEFAULT_CONNECT_TIMEOUT will be returned instead.

func (*TConfiguration) GetMaxFrameSize added in v0.14.0

func (tc *TConfiguration) GetMaxFrameSize() int32

GetMaxFrameSize returns the max frame size an implementation should follow.

It's nil-safe. DEFAULT_MAX_FRAME_SIZE will be returned if tc is nil.

If the configured max message size is smaller than the configured max frame size, the smaller one will be returned instead.

func (*TConfiguration) GetMaxMessageSize added in v0.14.0

func (tc *TConfiguration) GetMaxMessageSize() int32

GetMaxMessageSize returns the max message size an implementation should follow.

It's nil-safe. DEFAULT_MAX_MESSAGE_SIZE will be returned if tc is nil.

func (*TConfiguration) GetSocketTimeout added in v0.14.0

func (tc *TConfiguration) GetSocketTimeout() time.Duration

GetSocketTimeout returns the socket timeout should be used by TSocket and TSSLSocket.

It's nil-safe. If tc is nil, DEFAULT_SOCKET_TIMEOUT will be returned instead.

func (*TConfiguration) GetTBinaryStrictRead added in v0.14.0

func (tc *TConfiguration) GetTBinaryStrictRead() bool

GetTBinaryStrictRead returns the strict read configuration TBinaryProtocol should follow.

It's nil-safe. DEFAULT_TBINARY_STRICT_READ will be returned if either tc or tc.TBinaryStrictRead is nil.

func (*TConfiguration) GetTBinaryStrictWrite added in v0.14.0

func (tc *TConfiguration) GetTBinaryStrictWrite() bool

GetTBinaryStrictWrite returns the strict read configuration TBinaryProtocol should follow.

It's nil-safe. DEFAULT_TBINARY_STRICT_WRITE will be returned if either tc or tc.TBinaryStrictWrite is nil.

func (*TConfiguration) GetTHeaderProtocolID added in v0.14.0

func (tc *TConfiguration) GetTHeaderProtocolID() THeaderProtocolID

GetTHeaderProtocolID returns the THeaderProtocolID should be used by THeaderProtocol clients (for servers, they always use the same one as the client instead).

It's nil-safe. If either tc or tc.THeaderProtocolID is nil, THeaderProtocolDefault will be returned instead. THeaderProtocolDefault will also be returned if configured value is invalid.

func (*TConfiguration) GetTHeaderTransforms added in v0.21.0

func (tc *TConfiguration) GetTHeaderTransforms() []THeaderTransformID

GetTHeaderTransforms returns the THeaderTransformIDs to be applied on THeaderTransport writing.

It's nil-safe. If tc is nil, empty slice will be returned (meaning no transforms to be applied).

func (*TConfiguration) GetTLSConfig added in v0.14.0

func (tc *TConfiguration) GetTLSConfig() *tls.Config

GetTLSConfig returns the tls config should be used by TSSLSocket.

It's nil-safe. If tc is nil, nil will be returned instead.

type TConfigurationSetter added in v0.14.0

type TConfigurationSetter interface {
	SetTConfiguration(*TConfiguration)
}

TConfigurationSetter is an optional interface TProtocol, TTransport, TProtocolFactory, TTransportFactory, and other implementations can implement.

It's intended to be called during intializations. The behavior of calling SetTConfiguration on a TTransport/TProtocol in the middle of a message is undefined: It may or may not change the behavior of the current processing message, and it may even cause the current message to fail.

Note for implementations: SetTConfiguration might be called multiple times with the same value in quick successions due to the implementation of the propagation. Implementations should make SetTConfiguration as simple as possible (usually just overwrite the stored configuration and propagate it to the wrapped TTransports/TProtocols).

type TDebugProtocol

type TDebugProtocol struct {
	// Required. The actual TProtocol to do the read/write.
	Delegate TProtocol

	// Optional. The logger and prefix to log all the args/return values
	// from Delegate TProtocol calls.
	//
	// If Logger is nil, StdLogger using stdlib log package with os.Stderr
	// will be used. If disable logging is desired, set Logger to NopLogger
	// explicitly instead of leaving it as nil/unset.
	//
	// Deprecated: TDebugProtocol always use slog at debug level now.
	// This field will be removed in a future version.
	Logger Logger

	LogPrefix string

	// Optional. An TProtocol to duplicate everything read/written from Delegate.
	//
	// A typical use case of this is to use TSimpleJSONProtocol wrapping
	// TMemoryBuffer in a middleware to json logging requests/responses.
	//
	// This feature is not available from TDebugProtocolFactory. In order to
	// use it you have to construct TDebugProtocol directly, or set DuplicateTo
	// field after getting a TDebugProtocol from the factory.
	//
	// Deprecated: Please use TDuplicateToProtocol instead.
	DuplicateTo TProtocol
}

func (*TDebugProtocol) Flush

func (tdp *TDebugProtocol) Flush(ctx context.Context) (err error)

func (*TDebugProtocol) ReadBinary

func (tdp *TDebugProtocol) ReadBinary(ctx context.Context) (value []byte, err error)

func (*TDebugProtocol) ReadBool

func (tdp *TDebugProtocol) ReadBool(ctx context.Context) (value bool, err error)

func (*TDebugProtocol) ReadByte

func (tdp *TDebugProtocol) ReadByte(ctx context.Context) (value int8, err error)

func (*TDebugProtocol) ReadDouble

func (tdp *TDebugProtocol) ReadDouble(ctx context.Context) (value float64, err error)

func (*TDebugProtocol) ReadFieldBegin

func (tdp *TDebugProtocol) ReadFieldBegin(ctx context.Context) (name string, typeId TType, id int16, err error)

func (*TDebugProtocol) ReadFieldEnd

func (tdp *TDebugProtocol) ReadFieldEnd(ctx context.Context) (err error)

func (*TDebugProtocol) ReadI16

func (tdp *TDebugProtocol) ReadI16(ctx context.Context) (value int16, err error)

func (*TDebugProtocol) ReadI32

func (tdp *TDebugProtocol) ReadI32(ctx context.Context) (value int32, err error)

func (*TDebugProtocol) ReadI64

func (tdp *TDebugProtocol) ReadI64(ctx context.Context) (value int64, err error)

func (*TDebugProtocol) ReadListBegin

func (tdp *TDebugProtocol) ReadListBegin(ctx context.Context) (elemType TType, size int, err error)

func (*TDebugProtocol) ReadListEnd

func (tdp *TDebugProtocol) ReadListEnd(ctx context.Context) (err error)

func (*TDebugProtocol) ReadMapBegin

func (tdp *TDebugProtocol) ReadMapBegin(ctx context.Context) (keyType TType, valueType TType, size int, err error)

func (*TDebugProtocol) ReadMapEnd

func (tdp *TDebugProtocol) ReadMapEnd(ctx context.Context) (err error)

func (*TDebugProtocol) ReadMessageBegin

func (tdp *TDebugProtocol) ReadMessageBegin(ctx context.Context) (name string, typeId TMessageType, seqid int32, err error)

func (*TDebugProtocol) ReadMessageEnd

func (tdp *TDebugProtocol) ReadMessageEnd(ctx context.Context) (err error)

func (*TDebugProtocol) ReadSetBegin

func (tdp *TDebugProtocol) ReadSetBegin(ctx context.Context) (elemType TType, size int, err error)

func (*TDebugProtocol) ReadSetEnd

func (tdp *TDebugProtocol) ReadSetEnd(ctx context.Context) (err error)

func (*TDebugProtocol) ReadString

func (tdp *TDebugProtocol) ReadString(ctx context.Context) (value string, err error)

func (*TDebugProtocol) ReadStructBegin

func (tdp *TDebugProtocol) ReadStructBegin(ctx context.Context) (name string, err error)

func (*TDebugProtocol) ReadStructEnd

func (tdp *TDebugProtocol) ReadStructEnd(ctx context.Context) (err error)

func (*TDebugProtocol) ReadUUID added in v0.18.0

func (tdp *TDebugProtocol) ReadUUID(ctx context.Context) (value Tuuid, err error)

func (*TDebugProtocol) SetTConfiguration added in v0.14.0

func (tdp *TDebugProtocol) SetTConfiguration(conf *TConfiguration)

SetTConfiguration implements TConfigurationSetter for propagation.

func (*TDebugProtocol) Skip

func (tdp *TDebugProtocol) Skip(ctx context.Context, fieldType TType) (err error)

func (*TDebugProtocol) Transport

func (tdp *TDebugProtocol) Transport() TTransport

func (*TDebugProtocol) WriteBinary

func (tdp *TDebugProtocol) WriteBinary(ctx context.Context, value []byte) error

func (*TDebugProtocol) WriteBool

func (tdp *TDebugProtocol) WriteBool(ctx context.Context, value bool) error

func (*TDebugProtocol) WriteByte

func (tdp *TDebugProtocol) WriteByte(ctx context.Context, value int8) error

func (*TDebugProtocol) WriteDouble

func (tdp *TDebugProtocol) WriteDouble(ctx context.Context, value float64) error

func (*TDebugProtocol) WriteFieldBegin

func (tdp *TDebugProtocol) WriteFieldBegin(ctx context.Context, name string, typeId TType, id int16) error

func (*TDebugProtocol) WriteFieldEnd

func (tdp *TDebugProtocol) WriteFieldEnd(ctx context.Context) error

func (*TDebugProtocol) WriteFieldStop

func (tdp *TDebugProtocol) WriteFieldStop(ctx context.Context) error

func (*TDebugProtocol) WriteI16

func (tdp *TDebugProtocol) WriteI16(ctx context.Context, value int16) error

func (*TDebugProtocol) WriteI32

func (tdp *TDebugProtocol) WriteI32(ctx context.Context, value int32) error

func (*TDebugProtocol) WriteI64

func (tdp *TDebugProtocol) WriteI64(ctx context.Context, value int64) error

func (*TDebugProtocol) WriteListBegin

func (tdp *TDebugProtocol) WriteListBegin(ctx context.Context, elemType TType, size int) error

func (*TDebugProtocol) WriteListEnd

func (tdp *TDebugProtocol) WriteListEnd(ctx context.Context) error

func (*TDebugProtocol) WriteMapBegin

func (tdp *TDebugProtocol) WriteMapBegin(ctx context.Context, keyType TType, valueType TType, size int) error

func (*TDebugProtocol) WriteMapEnd

func (tdp *TDebugProtocol) WriteMapEnd(ctx context.Context) error

func (*TDebugProtocol) WriteMessageBegin

func (tdp *TDebugProtocol) WriteMessageBegin(ctx context.Context, name string, typeId TMessageType, seqid int32) error

func (*TDebugProtocol) WriteMessageEnd

func (tdp *TDebugProtocol) WriteMessageEnd(ctx context.Context) error

func (*TDebugProtocol) WriteSetBegin

func (tdp *TDebugProtocol) WriteSetBegin(ctx context.Context, elemType TType, size int) error

func (*TDebugProtocol) WriteSetEnd

func (tdp *TDebugProtocol) WriteSetEnd(ctx context.Context) error

func (*TDebugProtocol) WriteString

func (tdp *TDebugProtocol) WriteString(ctx context.Context, value string) error

func (*TDebugProtocol) WriteStructBegin

func (tdp *TDebugProtocol) WriteStructBegin(ctx context.Context, name string) error

func (*TDebugProtocol) WriteStructEnd

func (tdp *TDebugProtocol) WriteStructEnd(ctx context.Context) error

func (*TDebugProtocol) WriteUUID added in v0.18.0

func (tdp *TDebugProtocol) WriteUUID(ctx context.Context, value Tuuid) error

type TDebugProtocolFactory

type TDebugProtocolFactory struct {
	Underlying TProtocolFactory
	LogPrefix  string
	Logger     Logger
}

func NewTDebugProtocolFactory deprecated

func NewTDebugProtocolFactory(underlying TProtocolFactory, logPrefix string) *TDebugProtocolFactory

NewTDebugProtocolFactory creates a TDebugProtocolFactory.

Deprecated: Please use NewTDebugProtocolFactoryWithLogger or the struct itself instead. This version will use the default logger from standard library.

func NewTDebugProtocolFactoryWithLogger added in v0.14.0

func NewTDebugProtocolFactoryWithLogger(underlying TProtocolFactory, logPrefix string, logger Logger) *TDebugProtocolFactory

NewTDebugProtocolFactoryWithLogger creates a TDebugProtocolFactory.

func (*TDebugProtocolFactory) GetProtocol

func (t *TDebugProtocolFactory) GetProtocol(trans TTransport) TProtocol

type TDeserializer

type TDeserializer struct {
	Transport *TMemoryBuffer
	Protocol  TProtocol
}

func NewTDeserializer

func NewTDeserializer() *TDeserializer

func (*TDeserializer) Read

func (t *TDeserializer) Read(ctx context.Context, msg TStruct, b []byte) (err error)

func (*TDeserializer) ReadString

func (t *TDeserializer) ReadString(ctx context.Context, msg TStruct, s string) (err error)

type TDeserializerPool added in v0.14.0

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

TDeserializerPool is the thread-safe version of TDeserializer, it uses resource pool of TDeserializer under the hood.

It must be initialized with either NewTDeserializerPool or NewTDeserializerPoolSizeFactory.

func NewTDeserializerPool added in v0.14.0

func NewTDeserializerPool(f func() *TDeserializer) *TDeserializerPool

NewTDeserializerPool creates a new TDeserializerPool.

NewTDeserializer can be used as the arg here.

func NewTDeserializerPoolSizeFactory added in v0.14.0

func NewTDeserializerPoolSizeFactory(size int, factory TProtocolFactory) *TDeserializerPool

NewTDeserializerPoolSizeFactory creates a new TDeserializerPool with the given size and protocol factory.

Note that the size is not the limit. The TMemoryBuffer underneath can grow larger than that. It just dictates the initial size.

func (*TDeserializerPool) Read added in v0.14.0

func (t *TDeserializerPool) Read(ctx context.Context, msg TStruct, b []byte) error

func (*TDeserializerPool) ReadString added in v0.14.0

func (t *TDeserializerPool) ReadString(ctx context.Context, msg TStruct, s string) error

type TDuplicateToProtocol added in v0.17.0

type TDuplicateToProtocol struct {
	// Required. The actual TProtocol to do the read/write.
	Delegate TProtocol

	// Required. An TProtocol to duplicate everything read/written from Delegate.
	//
	// A typical use case of this is to use TSimpleJSONProtocol wrapping
	// TMemoryBuffer in a middleware to json logging requests/responses,
	// or wrapping a TTransport that counts bytes written to get the payload
	// sizes.
	//
	// DuplicateTo will be used as write only. For read calls on
	// TDuplicateToProtocol, the result read from Delegate will be written
	// to DuplicateTo.
	DuplicateTo TProtocol
}

func (*TDuplicateToProtocol) Flush added in v0.17.0

func (tdtp *TDuplicateToProtocol) Flush(ctx context.Context) (err error)

func (*TDuplicateToProtocol) ReadBinary added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadBinary(ctx context.Context) (value []byte, err error)

func (*TDuplicateToProtocol) ReadBool added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadBool(ctx context.Context) (value bool, err error)

func (*TDuplicateToProtocol) ReadByte added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadByte(ctx context.Context) (value int8, err error)

func (*TDuplicateToProtocol) ReadDouble added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadDouble(ctx context.Context) (value float64, err error)

func (*TDuplicateToProtocol) ReadFieldBegin added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadFieldBegin(ctx context.Context) (name string, typeId TType, id int16, err error)

func (*TDuplicateToProtocol) ReadFieldEnd added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadFieldEnd(ctx context.Context) (err error)

func (*TDuplicateToProtocol) ReadI16 added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadI16(ctx context.Context) (value int16, err error)

func (*TDuplicateToProtocol) ReadI32 added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadI32(ctx context.Context) (value int32, err error)

func (*TDuplicateToProtocol) ReadI64 added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadI64(ctx context.Context) (value int64, err error)

func (*TDuplicateToProtocol) ReadListBegin added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadListBegin(ctx context.Context) (elemType TType, size int, err error)

func (*TDuplicateToProtocol) ReadListEnd added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadListEnd(ctx context.Context) (err error)

func (*TDuplicateToProtocol) ReadMapBegin added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadMapBegin(ctx context.Context) (keyType TType, valueType TType, size int, err error)

func (*TDuplicateToProtocol) ReadMapEnd added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadMapEnd(ctx context.Context) (err error)

func (*TDuplicateToProtocol) ReadMessageBegin added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadMessageBegin(ctx context.Context) (name string, typeId TMessageType, seqid int32, err error)

func (*TDuplicateToProtocol) ReadMessageEnd added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadMessageEnd(ctx context.Context) (err error)

func (*TDuplicateToProtocol) ReadSetBegin added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadSetBegin(ctx context.Context) (elemType TType, size int, err error)

func (*TDuplicateToProtocol) ReadSetEnd added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadSetEnd(ctx context.Context) (err error)

func (*TDuplicateToProtocol) ReadString added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadString(ctx context.Context) (value string, err error)

func (*TDuplicateToProtocol) ReadStructBegin added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadStructBegin(ctx context.Context) (name string, err error)

func (*TDuplicateToProtocol) ReadStructEnd added in v0.17.0

func (tdtp *TDuplicateToProtocol) ReadStructEnd(ctx context.Context) (err error)

func (*TDuplicateToProtocol) ReadUUID added in v0.18.0

func (tdtp *TDuplicateToProtocol) ReadUUID(ctx context.Context) (value Tuuid, err error)

func (*TDuplicateToProtocol) SetTConfiguration added in v0.17.0

func (tdtp *TDuplicateToProtocol) SetTConfiguration(conf *TConfiguration)

SetTConfiguration implements TConfigurationSetter for propagation.

func (*TDuplicateToProtocol) Skip added in v0.17.0

func (tdtp *TDuplicateToProtocol) Skip(ctx context.Context, fieldType TType) (err error)

func (*TDuplicateToProtocol) Transport added in v0.17.0

func (tdtp *TDuplicateToProtocol) Transport() TTransport

func (*TDuplicateToProtocol) WriteBinary added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteBinary(ctx context.Context, value []byte) error

func (*TDuplicateToProtocol) WriteBool added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteBool(ctx context.Context, value bool) error

func (*TDuplicateToProtocol) WriteByte added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteByte(ctx context.Context, value int8) error

func (*TDuplicateToProtocol) WriteDouble added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteDouble(ctx context.Context, value float64) error

func (*TDuplicateToProtocol) WriteFieldBegin added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteFieldBegin(ctx context.Context, name string, typeId TType, id int16) error

func (*TDuplicateToProtocol) WriteFieldEnd added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteFieldEnd(ctx context.Context) error

func (*TDuplicateToProtocol) WriteFieldStop added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteFieldStop(ctx context.Context) error

func (*TDuplicateToProtocol) WriteI16 added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteI16(ctx context.Context, value int16) error

func (*TDuplicateToProtocol) WriteI32 added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteI32(ctx context.Context, value int32) error

func (*TDuplicateToProtocol) WriteI64 added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteI64(ctx context.Context, value int64) error

func (*TDuplicateToProtocol) WriteListBegin added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteListBegin(ctx context.Context, elemType TType, size int) error

func (*TDuplicateToProtocol) WriteListEnd added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteListEnd(ctx context.Context) error

func (*TDuplicateToProtocol) WriteMapBegin added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteMapBegin(ctx context.Context, keyType TType, valueType TType, size int) error

func (*TDuplicateToProtocol) WriteMapEnd added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteMapEnd(ctx context.Context) error

func (*TDuplicateToProtocol) WriteMessageBegin added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteMessageBegin(ctx context.Context, name string, typeId TMessageType, seqid int32) error

func (*TDuplicateToProtocol) WriteMessageEnd added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteMessageEnd(ctx context.Context) error

func (*TDuplicateToProtocol) WriteSetBegin added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteSetBegin(ctx context.Context, elemType TType, size int) error

func (*TDuplicateToProtocol) WriteSetEnd added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteSetEnd(ctx context.Context) error

func (*TDuplicateToProtocol) WriteString added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteString(ctx context.Context, value string) error

func (*TDuplicateToProtocol) WriteStructBegin added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteStructBegin(ctx context.Context, name string) error

func (*TDuplicateToProtocol) WriteStructEnd added in v0.17.0

func (tdtp *TDuplicateToProtocol) WriteStructEnd(ctx context.Context) error

func (*TDuplicateToProtocol) WriteUUID added in v0.18.0

func (tdtp *TDuplicateToProtocol) WriteUUID(ctx context.Context, value Tuuid) error

type TException

type TException interface {
	error

	TExceptionType() TExceptionType
}

Generic Thrift exception

func WrapTException added in v0.14.0

func WrapTException(err error) TException

WrapTException wraps an error into TException.

If err is nil or already TException, it's returned as-is. Otherwise it will be wraped into TException with TExceptionType() returning TExceptionTypeUnknown, and Unwrap() returning the original error.

type TExceptionType added in v0.14.0

type TExceptionType byte

TExceptionType is an enum type to categorize different "subclasses" of TExceptions.

const (
	TExceptionTypeUnknown     TExceptionType = iota
	TExceptionTypeCompiled                   // TExceptions defined in thrift files and generated by thrift compiler
	TExceptionTypeApplication                // TApplicationExceptions
	TExceptionTypeProtocol                   // TProtocolExceptions
	TExceptionTypeTransport                  // TTransportExceptions
)

TExceptionType values

type TFramedTransport

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

func NewTFramedTransport deprecated

func NewTFramedTransport(transport TTransport) *TFramedTransport

Deprecated: Use NewTFramedTransportConf instead.

func NewTFramedTransportConf added in v0.14.0

func NewTFramedTransportConf(transport TTransport, conf *TConfiguration) *TFramedTransport

func NewTFramedTransportMaxLength deprecated

func NewTFramedTransportMaxLength(transport TTransport, maxLength uint32) *TFramedTransport

Deprecated: Use NewTFramedTransportConf instead.

func (*TFramedTransport) Close

func (p *TFramedTransport) Close() error

func (*TFramedTransport) Flush

func (p *TFramedTransport) Flush(ctx context.Context) error

func (*TFramedTransport) IsOpen

func (p *TFramedTransport) IsOpen() bool

func (*TFramedTransport) Open

func (p *TFramedTransport) Open() error

func (*TFramedTransport) Read

func (p *TFramedTransport) Read(buf []byte) (read int, err error)

func (*TFramedTransport) ReadByte

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

func (*TFramedTransport) RemainingBytes

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

func (*TFramedTransport) SetTConfiguration added in v0.14.0

func (p *TFramedTransport) SetTConfiguration(cfg *TConfiguration)

SetTConfiguration implements TConfigurationSetter.

func (*TFramedTransport) Write

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

func (*TFramedTransport) WriteByte

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

func (*TFramedTransport) WriteString

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

type THeaderInfoType added in v0.13.0

type THeaderInfoType int32

THeaderInfoType is the type id of the info headers.

const (
	InfoKeyValue THeaderInfoType // 1

)

Supported THeaderInfoType values.

type THeaderMap added in v0.13.0

type THeaderMap map[string]string

THeaderMap is the type of the header map in THeader transport.

type THeaderProtocol added in v0.13.0

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

THeaderProtocol is a thrift protocol that implements THeader: https://github.com/apache/thrift/blob/master/doc/specs/HeaderFormat.md

It supports either binary or compact protocol as the wrapped protocol.

Most of the THeader handlings are happening inside THeaderTransport.

func NewTHeaderProtocol deprecated added in v0.13.0

func NewTHeaderProtocol(trans TTransport) *THeaderProtocol

Deprecated: Use NewTHeaderProtocolConf instead.

func NewTHeaderProtocolConf added in v0.14.0

func NewTHeaderProtocolConf(trans TTransport, conf *TConfiguration) *THeaderProtocol

NewTHeaderProtocolConf creates a new THeaderProtocol from the underlying transport with given TConfiguration.

The passed in transport will be wrapped with THeaderTransport.

Note that THeaderTransport handles frame and zlib by itself, so the underlying transport should be a raw socket transports (TSocket or TSSLSocket), instead of rich transports like TZlibTransport or TFramedTransport.

func (*THeaderProtocol) AddTransform deprecated added in v0.13.0

func (p *THeaderProtocol) AddTransform(transform THeaderTransformID) error

AddTransform add a transform for writing.

Deprecated: This only applies to the next message written, and the next read message will cause write transforms to be reset from what's configured in TConfiguration. For sticky transforms, use TConfiguration.THeaderTransforms instead.

func (*THeaderProtocol) ClearWriteHeaders added in v0.13.0

func (p *THeaderProtocol) ClearWriteHeaders()

ClearWriteHeaders clears all write headers previously set.

func (*THeaderProtocol) Flush added in v0.13.0

func (p *THeaderProtocol) Flush(ctx context.Context) error

func (*THeaderProtocol) GetReadHeaders added in v0.13.0

func (p *THeaderProtocol) GetReadHeaders() THeaderMap

GetReadHeaders returns the THeaderMap read from transport.

func (*THeaderProtocol) ReadBinary added in v0.13.0

func (p *THeaderProtocol) ReadBinary(ctx context.Context) (value []byte, err error)

func (*THeaderProtocol) ReadBool added in v0.13.0

func (p *THeaderProtocol) ReadBool(ctx context.Context) (value bool, err error)

func (*THeaderProtocol) ReadByte added in v0.13.0

func (p *THeaderProtocol) ReadByte(ctx context.Context) (value int8, err error)

func (*THeaderProtocol) ReadDouble added in v0.13.0

func (p *THeaderProtocol) ReadDouble(ctx context.Context) (value float64, err error)

func (*THeaderProtocol) ReadFieldBegin added in v0.13.0

func (p *THeaderProtocol) ReadFieldBegin(ctx context.Context) (name string, typeID TType, id int16, err error)

func (*THeaderProtocol) ReadFieldEnd added in v0.13.0

func (p *THeaderProtocol) ReadFieldEnd(ctx context.Context) error

func (*THeaderProtocol) ReadFrame added in v0.13.0

func (p *THeaderProtocol) ReadFrame(ctx context.Context) error

ReadFrame calls underlying THeaderTransport's ReadFrame function.

func (*THeaderProtocol) ReadI16 added in v0.13.0

func (p *THeaderProtocol) ReadI16(ctx context.Context) (value int16, err error)

func (*THeaderProtocol) ReadI32 added in v0.13.0

func (p *THeaderProtocol) ReadI32(ctx context.Context) (value int32, err error)

func (*THeaderProtocol) ReadI64 added in v0.13.0

func (p *THeaderProtocol) ReadI64(ctx context.Context) (value int64, err error)

func (*THeaderProtocol) ReadListBegin added in v0.13.0

func (p *THeaderProtocol) ReadListBegin(ctx context.Context) (elemType TType, size int, err error)

func (*THeaderProtocol) ReadListEnd added in v0.13.0

func (p *THeaderProtocol) ReadListEnd(ctx context.Context) error

func (*THeaderProtocol) ReadMapBegin added in v0.13.0

func (p *THeaderProtocol) ReadMapBegin(ctx context.Context) (keyType TType, valueType TType, size int, err error)

func (*THeaderProtocol) ReadMapEnd added in v0.13.0

func (p *THeaderProtocol) ReadMapEnd(ctx context.Context) error

func (*THeaderProtocol) ReadMessageBegin added in v0.13.0

func (p *THeaderProtocol) ReadMessageBegin(ctx context.Context) (name string, typeID TMessageType, seqID int32, err error)

func (*THeaderProtocol) ReadMessageEnd added in v0.13.0

func (p *THeaderProtocol) ReadMessageEnd(ctx context.Context) error

func (*THeaderProtocol) ReadSetBegin added in v0.13.0

func (p *THeaderProtocol) ReadSetBegin(ctx context.Context) (elemType TType, size int, err error)

func (*THeaderProtocol) ReadSetEnd added in v0.13.0

func (p *THeaderProtocol) ReadSetEnd(ctx context.Context) error

func (*THeaderProtocol) ReadString added in v0.13.0

func (p *THeaderProtocol) ReadString(ctx context.Context) (value string, err error)

func (*THeaderProtocol) ReadStructBegin added in v0.13.0

func (p *THeaderProtocol) ReadStructBegin(ctx context.Context) (name string, err error)

func (*THeaderProtocol) ReadStructEnd added in v0.13.0

func (p *THeaderProtocol) ReadStructEnd(ctx context.Context) error

func (*THeaderProtocol) ReadUUID added in v0.18.0

func (p *THeaderProtocol) ReadUUID(ctx context.Context) (value Tuuid, err error)

func (*THeaderProtocol) SetTConfiguration added in v0.14.0

func (p *THeaderProtocol) SetTConfiguration(cfg *TConfiguration)

SetTConfiguration implements TConfigurationSetter.

func (*THeaderProtocol) SetWriteHeader added in v0.13.0

func (p *THeaderProtocol) SetWriteHeader(key, value string)

SetWriteHeader sets a header for write.

func (*THeaderProtocol) Skip added in v0.13.0

func (p *THeaderProtocol) Skip(ctx context.Context, fieldType TType) error

func (*THeaderProtocol) Transport added in v0.13.0

func (p *THeaderProtocol) Transport() TTransport

Transport returns the underlying transport.

It's guaranteed to be of type *THeaderTransport.

func (*THeaderProtocol) WriteBinary added in v0.13.0

func (p *THeaderProtocol) WriteBinary(ctx context.Context, value []byte) error

func (*THeaderProtocol) WriteBool added in v0.13.0

func (p *THeaderProtocol) WriteBool(ctx context.Context, value bool) error

func (*THeaderProtocol) WriteByte added in v0.13.0

func (p *THeaderProtocol) WriteByte(ctx context.Context, value int8) error

func (*THeaderProtocol) WriteDouble added in v0.13.0

func (p *THeaderProtocol) WriteDouble(ctx context.Context, value float64) error

func (*THeaderProtocol) WriteFieldBegin added in v0.13.0

func (p *THeaderProtocol) WriteFieldBegin(ctx context.Context, name string, typeID TType, id int16) error

func (*THeaderProtocol) WriteFieldEnd added in v0.13.0

func (p *THeaderProtocol) WriteFieldEnd(ctx context.Context) error

func (*THeaderProtocol) WriteFieldStop added in v0.13.0

func (p *THeaderProtocol) WriteFieldStop(ctx context.Context) error

func (*THeaderProtocol) WriteI16 added in v0.13.0

func (p *THeaderProtocol) WriteI16(ctx context.Context, value int16) error

func (*THeaderProtocol) WriteI32 added in v0.13.0

func (p *THeaderProtocol) WriteI32(ctx context.Context, value int32) error

func (*THeaderProtocol) WriteI64 added in v0.13.0

func (p *THeaderProtocol) WriteI64(ctx context.Context, value int64) error

func (*THeaderProtocol) WriteListBegin added in v0.13.0

func (p *THeaderProtocol) WriteListBegin(ctx context.Context, elemType TType, size int) error

func (*THeaderProtocol) WriteListEnd added in v0.13.0

func (p *THeaderProtocol) WriteListEnd(ctx context.Context) error

func (*THeaderProtocol) WriteMapBegin added in v0.13.0

func (p *THeaderProtocol) WriteMapBegin(ctx context.Context, keyType TType, valueType TType, size int) error

func (*THeaderProtocol) WriteMapEnd added in v0.13.0

func (p *THeaderProtocol) WriteMapEnd(ctx context.Context) error

func (*THeaderProtocol) WriteMessageBegin added in v0.13.0

func (p *THeaderProtocol) WriteMessageBegin(ctx context.Context, name string, typeID TMessageType, seqID int32) error

func (*THeaderProtocol) WriteMessageEnd added in v0.13.0

func (p *THeaderProtocol) WriteMessageEnd(ctx context.Context) error

func (*THeaderProtocol) WriteSetBegin added in v0.13.0

func (p *THeaderProtocol) WriteSetBegin(ctx context.Context, elemType TType, size int) error

func (*THeaderProtocol) WriteSetEnd added in v0.13.0

func (p *THeaderProtocol) WriteSetEnd(ctx context.Context) error

func (*THeaderProtocol) WriteString added in v0.13.0

func (p *THeaderProtocol) WriteString(ctx context.Context, value string) error

func (*THeaderProtocol) WriteStructBegin added in v0.13.0

func (p *THeaderProtocol) WriteStructBegin(ctx context.Context, name string) error

func (*THeaderProtocol) WriteStructEnd added in v0.13.0

func (p *THeaderProtocol) WriteStructEnd(ctx context.Context) error

func (*THeaderProtocol) WriteUUID added in v0.18.0

func (p *THeaderProtocol) WriteUUID(ctx context.Context, value Tuuid) error

type THeaderProtocolID added in v0.13.0

type THeaderProtocolID int32

THeaderProtocolID is the wrapped protocol id used in THeader.

const (
	THeaderProtocolBinary  THeaderProtocolID = 0x00
	THeaderProtocolCompact THeaderProtocolID = 0x02
	THeaderProtocolDefault                   = THeaderProtocolBinary
)

Supported THeaderProtocolID values.

func THeaderProtocolIDPtr added in v0.14.0

func THeaderProtocolIDPtr(id THeaderProtocolID) (*THeaderProtocolID, error)

THeaderProtocolIDPtr validates and returns the pointer to id.

If id is not a valid THeaderProtocolID, a pointer to THeaderProtocolDefault and the validation error will be returned.

func THeaderProtocolIDPtrMust added in v0.14.0

func THeaderProtocolIDPtrMust(id THeaderProtocolID) *THeaderProtocolID

THeaderProtocolIDPtrMust validates and returns the pointer to id.

It's similar to THeaderProtocolIDPtr, but it panics on validation errors instead of returning them.

func (THeaderProtocolID) GetProtocol added in v0.13.0

func (id THeaderProtocolID) GetProtocol(trans TTransport) (TProtocol, error)

GetProtocol gets the corresponding TProtocol from the wrapped protocol id.

func (THeaderProtocolID) Validate added in v0.14.0

func (id THeaderProtocolID) Validate() error

Validate checks whether the THeaderProtocolID is a valid/supported one.

type THeaderResponseHelper added in v0.14.0

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

THeaderResponseHelper defines THeader related TResponseHelper functions.

The zero value of *THeaderResponseHelper is valid with all helper functions being no-op.

func NewTHeaderResponseHelper added in v0.14.0

func NewTHeaderResponseHelper(proto TProtocol) *THeaderResponseHelper

NewTHeaderResponseHelper creates a new THeaderResponseHelper from the underlying TProtocol.

func (*THeaderResponseHelper) ClearHeaders added in v0.14.0

func (h *THeaderResponseHelper) ClearHeaders()

ClearHeaders clears all the response headers previously set.

It's no-op if the underlying protocol/transport does not support THeader.

func (*THeaderResponseHelper) SetHeader added in v0.14.0

func (h *THeaderResponseHelper) SetHeader(key, value string)

SetHeader sets a response header.

It's no-op if the underlying protocol/transport does not support THeader.

type THeaderTransformID added in v0.13.0

type THeaderTransformID int32

THeaderTransformID defines the numeric id of the transform used.

const (
	TransformNone THeaderTransformID = iota // 0, no special handling
	TransformZlib                           // 1, zlib
)

THeaderTransformID values.

Values not defined here are not currently supported, namely HMAC and Snappy.

type THeaderTransport added in v0.13.0

type THeaderTransport struct {
	SequenceID int32
	Flags      uint32
	// contains filtered or unexported fields
}

THeaderTransport is a Transport mode that implements THeader.

Note that THeaderTransport handles frame and zlib by itself, so the underlying transport should be a raw socket transports (TSocket or TSSLSocket), instead of rich transports like TZlibTransport or TFramedTransport.

func NewTHeaderTransport deprecated added in v0.13.0

func NewTHeaderTransport(trans TTransport) *THeaderTransport

Deprecated: Use NewTHeaderTransportConf instead.

func NewTHeaderTransportConf added in v0.14.0

func NewTHeaderTransportConf(trans TTransport, conf *TConfiguration) *THeaderTransport

NewTHeaderTransportConf creates THeaderTransport from the underlying transport, with given TConfiguration attached.

If trans is already a *THeaderTransport, it will be returned as is, but with TConfiguration overridden by the value passed in.

The protocol ID in TConfiguration is only useful for client transports. For servers, the protocol ID will be overridden again to the one set by the client, to ensure that servers always speak the same dialect as the client.

func (*THeaderTransport) AddTransform added in v0.13.0

func (t *THeaderTransport) AddTransform(transform THeaderTransformID) error

AddTransform add a transform for writing.

NOTE: This is provided as a low-level API, but in general you should use TConfiguration.THeaderTransforms to set transforms for writing instead.

func (*THeaderTransport) ClearWriteHeaders added in v0.13.0

func (t *THeaderTransport) ClearWriteHeaders()

ClearWriteHeaders clears all write headers previously set.

func (*THeaderTransport) Close added in v0.13.0

func (t *THeaderTransport) Close() error

Close closes the transport, along with its underlying transport.

func (*THeaderTransport) Flush added in v0.13.0

func (t *THeaderTransport) Flush(ctx context.Context) error

Flush writes the appropriate header and the write buffer to the underlying transport.

func (*THeaderTransport) GetReadHeaders added in v0.13.0

func (t *THeaderTransport) GetReadHeaders() THeaderMap

GetReadHeaders returns the THeaderMap read from transport.

func (*THeaderTransport) IsOpen added in v0.13.0

func (t *THeaderTransport) IsOpen() bool

IsOpen calls the underlying transport's IsOpen function.

func (*THeaderTransport) Open added in v0.13.0

func (t *THeaderTransport) Open() error

Open calls the underlying transport's Open function.

func (*THeaderTransport) Protocol added in v0.13.0

func (t *THeaderTransport) Protocol() THeaderProtocolID

Protocol returns the wrapped protocol id used in this THeaderTransport.

func (*THeaderTransport) Read added in v0.13.0

func (t *THeaderTransport) Read(p []byte) (read int, err error)

func (*THeaderTransport) ReadFrame added in v0.13.0

func (t *THeaderTransport) ReadFrame(ctx context.Context) error

ReadFrame tries to read the frame header, guess the client type, and handle unframed clients.

func (*THeaderTransport) RemainingBytes added in v0.13.0

func (t *THeaderTransport) RemainingBytes() uint64

RemainingBytes calls underlying transport's RemainingBytes.

Even in framed cases, because of all the possible compression transforms involved, the remaining frame size is likely to be different from the actual remaining readable bytes, so we don't bother to keep tracking the remaining frame size by ourselves and just use the underlying transport's RemainingBytes directly.

func (*THeaderTransport) SetTConfiguration added in v0.14.0

func (t *THeaderTransport) SetTConfiguration(cfg *TConfiguration)

SetTConfiguration implements TConfigurationSetter.

func (*THeaderTransport) SetWriteHeader added in v0.13.0

func (t *THeaderTransport) SetWriteHeader(key, value string)

SetWriteHeader sets a header for write.

func (*THeaderTransport) Write added in v0.13.0

func (t *THeaderTransport) Write(p []byte) (int, error)

Write writes data to the write buffer.

You need to call Flush to actually write them to the transport.

type THeaderTransportFactory added in v0.13.0

type THeaderTransportFactory struct {
	// The underlying factory, could be nil.
	Factory TTransportFactory
	// contains filtered or unexported fields
}

THeaderTransportFactory is a TTransportFactory implementation to create THeaderTransport.

It also implements TConfigurationSetter.

func (*THeaderTransportFactory) GetTransport added in v0.13.0

func (f *THeaderTransportFactory) GetTransport(trans TTransport) (TTransport, error)

GetTransport implements TTransportFactory.

func (*THeaderTransportFactory) SetTConfiguration added in v0.14.0

func (f *THeaderTransportFactory) SetTConfiguration(cfg *TConfiguration)

SetTConfiguration implements TConfigurationSetter.

type THttpClient

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

func (*THttpClient) Close

func (p *THttpClient) Close() error

func (*THttpClient) DelHeader

func (p *THttpClient) DelHeader(key string)

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

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

func (*THttpClient) Flush

func (p *THttpClient) Flush(ctx context.Context) error

func (*THttpClient) GetHeader

func (p *THttpClient) 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 TTransport as a THttpClient type like so:

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

func (*THttpClient) IsOpen

func (p *THttpClient) IsOpen() bool

func (*THttpClient) Open

func (p *THttpClient) Open() error

func (*THttpClient) Read

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

func (*THttpClient) ReadByte

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

func (*THttpClient) RemainingBytes

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

func (*THttpClient) SetHeader

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

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

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

func (*THttpClient) Write

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

func (*THttpClient) WriteByte

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

func (*THttpClient) WriteString

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

type THttpClientOptions

type THttpClientOptions struct {
	// If nil, DefaultHttpClient is used
	Client *http.Client
}

type THttpClientTransportFactory

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

func NewTHttpClientTransportFactory

func NewTHttpClientTransportFactory(url string) *THttpClientTransportFactory

func NewTHttpClientTransportFactoryWithOptions

func NewTHttpClientTransportFactoryWithOptions(url string, options THttpClientOptions) *THttpClientTransportFactory

func NewTHttpPostClientTransportFactory deprecated

func NewTHttpPostClientTransportFactory(url string) *THttpClientTransportFactory

Deprecated: Use NewTHttpClientTransportFactory instead.

func NewTHttpPostClientTransportFactoryWithOptions deprecated

func NewTHttpPostClientTransportFactoryWithOptions(url string, options THttpClientOptions) *THttpClientTransportFactory

Deprecated: Use NewTHttpClientTransportFactoryWithOptions instead.

func (*THttpClientTransportFactory) GetTransport

func (p *THttpClientTransportFactory) GetTransport(trans TTransport) (TTransport, error)

type TJSONProtocol

type TJSONProtocol struct {
	*TSimpleJSONProtocol
}

JSON protocol implementation for thrift. Utilizes Simple JSON protocol

func NewTJSONProtocol

func NewTJSONProtocol(t TTransport) *TJSONProtocol

Constructor

func (*TJSONProtocol) Flush

func (p *TJSONProtocol) Flush(ctx context.Context) (err error)

func (*TJSONProtocol) OutputElemListBegin

func (p *TJSONProtocol) OutputElemListBegin(elemType TType, size int) error

func (*TJSONProtocol) ParseElemListBegin

func (p *TJSONProtocol) ParseElemListBegin() (elemType TType, size int, e error)

func (*TJSONProtocol) ReadBinary

func (p *TJSONProtocol) ReadBinary(ctx context.Context) ([]byte, error)

func (*TJSONProtocol) ReadBool

func (p *TJSONProtocol) ReadBool(ctx context.Context) (bool, error)

func (*TJSONProtocol) ReadByte

func (p *TJSONProtocol) ReadByte(ctx context.Context) (int8, error)

func (*TJSONProtocol) ReadDouble

func (p *TJSONProtocol) ReadDouble(ctx context.Context) (float64, error)

func (*TJSONProtocol) ReadFieldBegin

func (p *TJSONProtocol) ReadFieldBegin(ctx context.Context) (string, TType, int16, error)

func (*TJSONProtocol) ReadFieldEnd

func (p *TJSONProtocol) ReadFieldEnd(ctx context.Context) error

func (*TJSONProtocol) ReadI16

func (p *TJSONProtocol) ReadI16(ctx context.Context) (int16, error)

func (*TJSONProtocol) ReadI32

func (p *TJSONProtocol) ReadI32(ctx context.Context) (int32, error)

func (*TJSONProtocol) ReadI64

func (p *TJSONProtocol) ReadI64(ctx context.Context) (int64, error)

func (*TJSONProtocol) ReadListBegin

func (p *TJSONProtocol) ReadListBegin(ctx context.Context) (elemType TType, size int, e error)

func (*TJSONProtocol) ReadListEnd

func (p *TJSONProtocol) ReadListEnd(ctx context.Context) error

func (*TJSONProtocol) ReadMapBegin

func (p *TJSONProtocol) ReadMapBegin(ctx context.Context) (keyType TType, valueType TType, size int, e error)

func (*TJSONProtocol) ReadMapEnd

func (p *TJSONProtocol) ReadMapEnd(ctx context.Context) error

func (*TJSONProtocol) ReadMessageBegin

func (p *TJSONProtocol) ReadMessageBegin(ctx context.Context) (name string, typeId TMessageType, seqId int32, err error)

Reading methods.

func (*TJSONProtocol) ReadMessageEnd

func (p *TJSONProtocol) ReadMessageEnd(ctx context.Context) error

func (*TJSONProtocol) ReadSetBegin

func (p *TJSONProtocol) ReadSetBegin(ctx context.Context) (elemType TType, size int, e error)

func (*TJSONProtocol) ReadSetEnd

func (p *TJSONProtocol) ReadSetEnd(ctx context.Context) error

func (*TJSONProtocol) ReadString

func (p *TJSONProtocol) ReadString(ctx context.Context) (string, error)

func (*TJSONProtocol) ReadStructBegin

func (p *TJSONProtocol) ReadStructBegin(ctx context.Context) (name string, err error)

func (*TJSONProtocol) ReadStructEnd

func (p *TJSONProtocol) ReadStructEnd(ctx context.Context) error

func (*TJSONProtocol) Skip

func (p *TJSONProtocol) Skip(ctx context.Context, fieldType TType) (err error)

func (*TJSONProtocol) StringToTypeId

func (p *TJSONProtocol) StringToTypeId(fieldType string) (TType, error)

func (*TJSONProtocol) Transport

func (p *TJSONProtocol) Transport() TTransport

func (*TJSONProtocol) TypeIdToString

func (p *TJSONProtocol) TypeIdToString(fieldType TType) (string, error)

func (*TJSONProtocol) WriteBinary

func (p *TJSONProtocol) WriteBinary(ctx context.Context, v []byte) error

func (*TJSONProtocol) WriteBool

func (p *TJSONProtocol) WriteBool(ctx context.Context, b bool) error

func (*TJSONProtocol) WriteByte

func (p *TJSONProtocol) WriteByte(ctx context.Context, b int8) error

func (*TJSONProtocol) WriteDouble

func (p *TJSONProtocol) WriteDouble(ctx context.Context, v float64) error

func (*TJSONProtocol) WriteFieldBegin

func (p *TJSONProtocol) WriteFieldBegin(ctx context.Context, name string, typeId TType, id int16) error

func (*TJSONProtocol) WriteFieldEnd

func (p *TJSONProtocol) WriteFieldEnd(ctx context.Context) error

func (*TJSONProtocol) WriteFieldStop

func (p *TJSONProtocol) WriteFieldStop(ctx context.Context) error

func (*TJSONProtocol) WriteI16

func (p *TJSONProtocol) WriteI16(ctx context.Context, v int16) error

func (*TJSONProtocol) WriteI32

func (p *TJSONProtocol) WriteI32(ctx context.Context, v int32) error

func (*TJSONProtocol) WriteI64

func (p *TJSONProtocol) WriteI64(ctx context.Context, v int64) error

func (*TJSONProtocol) WriteListBegin

func (p *TJSONProtocol) WriteListBegin(ctx context.Context, elemType TType, size int) error

func (*TJSONProtocol) WriteListEnd

func (p *TJSONProtocol) WriteListEnd(ctx context.Context) error

func (*TJSONProtocol) WriteMapBegin

func (p *TJSONProtocol) WriteMapBegin(ctx context.Context, keyType TType, valueType TType, size int) error

func (*TJSONProtocol) WriteMapEnd

func (p *TJSONProtocol) WriteMapEnd(ctx context.Context) error

func (*TJSONProtocol) WriteMessageBegin

func (p *TJSONProtocol) WriteMessageBegin(ctx context.Context, name string, typeId TMessageType, seqId int32) error

func (*TJSONProtocol) WriteMessageEnd

func (p *TJSONProtocol) WriteMessageEnd(ctx context.Context) error

func (*TJSONProtocol) WriteSetBegin

func (p *TJSONProtocol) WriteSetBegin(ctx context.Context, elemType TType, size int) error

func (*TJSONProtocol) WriteSetEnd

func (p *TJSONProtocol) WriteSetEnd(ctx context.Context) error

func (*TJSONProtocol) WriteString

func (p *TJSONProtocol) WriteString(ctx context.Context, v string) error

func (*TJSONProtocol) WriteStructBegin

func (p *TJSONProtocol) WriteStructBegin(ctx context.Context, name string) error

func (*TJSONProtocol) WriteStructEnd

func (p *TJSONProtocol) WriteStructEnd(ctx context.Context) error

type TJSONProtocolFactory

type TJSONProtocolFactory struct{}

Factory

func NewTJSONProtocolFactory

func NewTJSONProtocolFactory() *TJSONProtocolFactory

func (*TJSONProtocolFactory) GetProtocol

func (p *TJSONProtocolFactory) GetProtocol(trans TTransport) TProtocol

type TMemoryBuffer

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

Memory buffer-based implementation of the TTransport interface.

func NewTMemoryBuffer

func NewTMemoryBuffer() *TMemoryBuffer

func NewTMemoryBufferLen

func NewTMemoryBufferLen(size int) *TMemoryBuffer

func (*TMemoryBuffer) Close

func (p *TMemoryBuffer) Close() error

func (*TMemoryBuffer) Flush

func (p *TMemoryBuffer) Flush(ctx context.Context) error

Flushing a memory buffer is a no-op

func (*TMemoryBuffer) IsOpen

func (p *TMemoryBuffer) IsOpen() bool

func (*TMemoryBuffer) Open

func (p *TMemoryBuffer) Open() error

func (*TMemoryBuffer) RemainingBytes

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

type TMemoryBufferTransportFactory

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

func NewTMemoryBufferTransportFactory

func NewTMemoryBufferTransportFactory(size int) *TMemoryBufferTransportFactory

func (*TMemoryBufferTransportFactory) GetTransport

func (p *TMemoryBufferTransportFactory) GetTransport(trans TTransport) (TTransport, error)

type TMessageType

type TMessageType int32

Message type constants in the Thrift protocol.

const (
	INVALID_TMESSAGE_TYPE TMessageType = 0
	CALL                  TMessageType = 1
	REPLY                 TMessageType = 2
	EXCEPTION             TMessageType = 3
	ONEWAY                TMessageType = 4
)

type TMultiplexedProcessor

type TMultiplexedProcessor struct {
	DefaultProcessor TProcessor
	// contains filtered or unexported fields
}

func NewTMultiplexedProcessor

func NewTMultiplexedProcessor() *TMultiplexedProcessor

func (*TMultiplexedProcessor) AddToProcessorMap added in v0.14.0

func (t *TMultiplexedProcessor) AddToProcessorMap(name string, processorFunc TProcessorFunction)

AddToProcessorMap updates the underlying TProcessor ProccessorMaps depending on the format of "name".

If "name" is in the format "{ProcessorName}{MULTIPLEXED_SEPARATOR}{FunctionName}", then it sets the given TProcessorFunction on the inner TProcessor with the ProcessorName component using the FunctionName component.

If "name" is just in the format "{FunctionName}", that is to say there is no MULTIPLEXED_SEPARATOR, and the TMultiplexedProcessor has a DefaultProcessor configured, then it will set the given TProcessorFunction on the DefaultProcessor using the given name.

If there is not a TProcessor available for the given name, then this function does nothing. This can happen when there is no TProcessor registered for the given ProcessorName or if all that is given is the FunctionName and there is no DefaultProcessor set.

func (*TMultiplexedProcessor) Process

func (t *TMultiplexedProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException)

func (*TMultiplexedProcessor) ProcessorMap added in v0.14.0

func (t *TMultiplexedProcessor) ProcessorMap() map[string]TProcessorFunction

ProcessorMap returns a mapping of "{ProcessorName}{MULTIPLEXED_SEPARATOR}{FunctionName}" to TProcessorFunction for any registered processors. If there is also a DefaultProcessor, the keys for the methods on that processor will simply be "{FunctionName}". If the TMultiplexedProcessor has both a DefaultProcessor and other registered processors, then the keys will be a mix of both formats.

The implementation differs with other TProcessors in that the map returned is a new map, while most TProcessors just return their internal mapping directly. This means that edits to the map returned by this implementation of ProcessorMap will not affect the underlying mapping within the TMultiplexedProcessor.

func (*TMultiplexedProcessor) RegisterDefault

func (t *TMultiplexedProcessor) RegisterDefault(processor TProcessor)

func (*TMultiplexedProcessor) RegisterProcessor

func (t *TMultiplexedProcessor) RegisterProcessor(name string, processor TProcessor)

type TMultiplexedProtocol

type TMultiplexedProtocol struct {
	TProtocol
	// contains filtered or unexported fields
}

func NewTMultiplexedProtocol

func NewTMultiplexedProtocol(protocol TProtocol, serviceName string) *TMultiplexedProtocol

func (*TMultiplexedProtocol) WriteMessageBegin

func (t *TMultiplexedProtocol) WriteMessageBegin(ctx context.Context, name string, typeId TMessageType, seqid int32) error

type TProcessor

type TProcessor interface {
	Process(ctx context.Context, in, out TProtocol) (bool, TException)

	// ProcessorMap returns a map of thrift method names to TProcessorFunctions.
	ProcessorMap() map[string]TProcessorFunction

	// AddToProcessorMap adds the given TProcessorFunction to the internal
	// processor map at the given key.
	//
	// If one is already set at the given key, it will be replaced with the new
	// TProcessorFunction.
	AddToProcessorMap(string, TProcessorFunction)
}

A processor is a generic object which operates upon an input stream and writes to some output stream.

func WrapProcessor added in v0.14.0

func WrapProcessor(processor TProcessor, middlewares ...ProcessorMiddleware) TProcessor

WrapProcessor takes an existing TProcessor and wraps each of its inner TProcessorFunctions with the middlewares passed in and returns it.

Middlewares will be called in the order that they are defined:

  1. Middlewares[0]
  2. Middlewares[1] ... N. Middlewares[n]

type TProcessorFactory

type TProcessorFactory interface {
	GetProcessor(trans TTransport) TProcessor
}

The default processor factory just returns a singleton instance.

func NewTProcessorFactory

func NewTProcessorFactory(p TProcessor) TProcessorFactory

type TProcessorFunction

type TProcessorFunction interface {
	Process(ctx context.Context, seqId int32, in, out TProtocol) (bool, TException)
}

type TProcessorFunctionFactory

type TProcessorFunctionFactory interface {
	GetProcessorFunction(trans TTransport) TProcessorFunction
}

*

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

type TProtocol

type TProtocol interface {
	WriteMessageBegin(ctx context.Context, name string, typeId TMessageType, seqid int32) error
	WriteMessageEnd(ctx context.Context) error
	WriteStructBegin(ctx context.Context, name string) error
	WriteStructEnd(ctx context.Context) error
	WriteFieldBegin(ctx context.Context, name string, typeId TType, id int16) error
	WriteFieldEnd(ctx context.Context) error
	WriteFieldStop(ctx context.Context) error
	WriteMapBegin(ctx context.Context, keyType TType, valueType TType, size int) error
	WriteMapEnd(ctx context.Context) error
	WriteListBegin(ctx context.Context, elemType TType, size int) error
	WriteListEnd(ctx context.Context) error
	WriteSetBegin(ctx context.Context, elemType TType, size int) error
	WriteSetEnd(ctx context.Context) error
	WriteBool(ctx context.Context, value bool) error
	WriteByte(ctx context.Context, value int8) error
	WriteI16(ctx context.Context, value int16) error
	WriteI32(ctx context.Context, value int32) error
	WriteI64(ctx context.Context, value int64) error
	WriteDouble(ctx context.Context, value float64) error
	WriteString(ctx context.Context, value string) error
	WriteBinary(ctx context.Context, value []byte) error
	WriteUUID(ctx context.Context, value Tuuid) error

	ReadMessageBegin(ctx context.Context) (name string, typeId TMessageType, seqid int32, err error)
	ReadMessageEnd(ctx context.Context) error
	ReadStructBegin(ctx context.Context) (name string, err error)
	ReadStructEnd(ctx context.Context) error
	ReadFieldBegin(ctx context.Context) (name string, typeId TType, id int16, err error)
	ReadFieldEnd(ctx context.Context) error
	ReadMapBegin(ctx context.Context) (keyType TType, valueType TType, size int, err error)
	ReadMapEnd(ctx context.Context) error
	ReadListBegin(ctx context.Context) (elemType TType, size int, err error)
	ReadListEnd(ctx context.Context) error
	ReadSetBegin(ctx context.Context) (elemType TType, size int, err error)
	ReadSetEnd(ctx context.Context) error
	ReadBool(ctx context.Context) (value bool, err error)
	ReadByte(ctx context.Context) (value int8, err error)
	ReadI16(ctx context.Context) (value int16, err error)
	ReadI32(ctx context.Context) (value int32, err error)
	ReadI64(ctx context.Context) (value int64, err error)
	ReadDouble(ctx context.Context) (value float64, err error)
	ReadString(ctx context.Context) (value string, err error)
	ReadBinary(ctx context.Context) (value []byte, err error)
	ReadUUID(ctx context.Context) (value Tuuid, err error)

	Skip(ctx context.Context, fieldType TType) (err error)
	Flush(ctx context.Context) (err error)

	Transport() TTransport
}

type TProtocolException

type TProtocolException interface {
	TException
	TypeId() int
}

Thrift Protocol exception

func NewTProtocolException

func NewTProtocolException(err error) TProtocolException

func NewTProtocolExceptionWithType

func NewTProtocolExceptionWithType(errType int, err error) TProtocolException

type TProtocolFactory

type TProtocolFactory interface {
	GetProtocol(trans TTransport) TProtocol
}

Factory interface for constructing protocol instances.

func NewTHeaderProtocolFactory deprecated added in v0.13.0

func NewTHeaderProtocolFactory() TProtocolFactory

Deprecated: Use NewTHeaderProtocolFactoryConf instead.

func NewTHeaderProtocolFactoryConf added in v0.14.0

func NewTHeaderProtocolFactoryConf(conf *TConfiguration) TProtocolFactory

NewTHeaderProtocolFactoryConf creates a factory for THeader with given TConfiguration.

func TProtocolFactoryConf added in v0.14.0

func TProtocolFactoryConf(delegate TProtocolFactory, conf *TConfiguration) TProtocolFactory

TProtocolFactoryConf wraps a TProtocolFactory to propagate TConfiguration on the factory's GetProtocol calls.

type TResponseHelper added in v0.14.0

type TResponseHelper struct {
	// THeader related functions
	*THeaderResponseHelper
}

TResponseHelper defines a object with a set of helper functions that can be retrieved from the context object passed into server handler functions.

Use GetResponseHelper to retrieve the injected TResponseHelper implementation from the context object.

The zero value of TResponseHelper is valid with all helper functions being no-op.

func GetResponseHelper added in v0.14.0

func GetResponseHelper(ctx context.Context) (helper TResponseHelper, ok bool)

GetResponseHelper retrieves the TResponseHelper implementation injected into the context object.

If no helper was found in the context object, a nop helper with ok == false will be returned.

type TRichTransport

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

	ContextFlusher
	ReadSizeProvider
	// contains filtered or unexported methods
}

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

type TSSLServerSocket

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

func NewTSSLServerSocket

func NewTSSLServerSocket(listenAddr string, cfg *tls.Config) (*TSSLServerSocket, error)

func NewTSSLServerSocketTimeout

func NewTSSLServerSocketTimeout(listenAddr string, cfg *tls.Config, clientTimeout time.Duration) (*TSSLServerSocket, error)

func (*TSSLServerSocket) Accept

func (p *TSSLServerSocket) Accept() (TTransport, error)

func (*TSSLServerSocket) Addr

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

func (*TSSLServerSocket) Close

func (p *TSSLServerSocket) Close() error

func (*TSSLServerSocket) Interrupt

func (p *TSSLServerSocket) Interrupt() error

func (*TSSLServerSocket) IsListening

func (p *TSSLServerSocket) IsListening() bool

Checks whether the socket is listening.

func (*TSSLServerSocket) Listen

func (p *TSSLServerSocket) Listen() error

func (*TSSLServerSocket) Open

func (p *TSSLServerSocket) Open() error

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

type TSSLSocket

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

func NewTSSLSocket deprecated

func NewTSSLSocket(hostPort string, cfg *tls.Config) (*TSSLSocket, error)

Deprecated: Use NewTSSLSocketConf instead.

func NewTSSLSocketConf added in v0.14.0

func NewTSSLSocketConf(hostPort string, conf *TConfiguration) *TSSLSocket

NewTSSLSocketConf creates a net.Conn-backed TTransport, given a host and port.

Example:

trans := thrift.NewTSSLSocketConf("localhost:9090", &TConfiguration{
    ConnectTimeout: time.Second, // Use 0 for no timeout
    SocketTimeout:  time.Second, // Use 0 for no timeout

    TLSConfig: &tls.Config{
        // Fill in tls config here.
    }
})

func NewTSSLSocketFromAddrConf added in v0.14.0

func NewTSSLSocketFromAddrConf(addr net.Addr, conf *TConfiguration) *TSSLSocket

NewTSSLSocketFromAddrConf creates a TSSLSocket from a net.Addr.

func NewTSSLSocketFromAddrTimeout deprecated

func NewTSSLSocketFromAddrTimeout(addr net.Addr, cfg *tls.Config, connectTimeout, socketTimeout time.Duration) *TSSLSocket

Deprecated: Use NewTSSLSocketFromAddrConf instead.

func NewTSSLSocketFromConnConf added in v0.14.0

func NewTSSLSocketFromConnConf(conn net.Conn, conf *TConfiguration) *TSSLSocket

NewTSSLSocketFromConnConf creates a TSSLSocket from an existing net.Conn.

func NewTSSLSocketFromConnTimeout deprecated

func NewTSSLSocketFromConnTimeout(conn net.Conn, cfg *tls.Config, socketTimeout time.Duration) *TSSLSocket

Deprecated: Use NewTSSLSocketFromConnConf instead.

func NewTSSLSocketTimeout deprecated

func NewTSSLSocketTimeout(hostPort string, cfg *tls.Config, connectTimeout, socketTimeout time.Duration) (*TSSLSocket, error)

Deprecated: Use NewTSSLSocketConf instead.

func (*TSSLSocket) Close

func (p *TSSLSocket) Close() error

Closes the socket.

func (*TSSLSocket) Conn

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

Retrieve the underlying net.Conn

func (*TSSLSocket) Flush

func (p *TSSLSocket) Flush(ctx context.Context) error

func (*TSSLSocket) Interrupt

func (p *TSSLSocket) Interrupt() error

func (*TSSLSocket) IsOpen

func (p *TSSLSocket) IsOpen() bool

Returns true if the connection is open

func (*TSSLSocket) Open

func (p *TSSLSocket) Open() error

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

func (*TSSLSocket) Read

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

func (*TSSLSocket) RemainingBytes

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

func (*TSSLSocket) SetConnTimeout added in v0.14.0

func (p *TSSLSocket) SetConnTimeout(timeout time.Duration) error

Sets the connect timeout

func (*TSSLSocket) SetSocketTimeout added in v0.14.0

func (p *TSSLSocket) SetSocketTimeout(timeout time.Duration) error

Sets the socket timeout

func (*TSSLSocket) SetTConfiguration added in v0.14.0

func (p *TSSLSocket) SetTConfiguration(conf *TConfiguration)

SetTConfiguration implements TConfigurationSetter.

It can be used to change connect and socket timeouts.

func (*TSSLSocket) Write

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

type TSerializer

type TSerializer struct {
	Transport *TMemoryBuffer
	Protocol  TProtocol
}

func NewTSerializer

func NewTSerializer() *TSerializer

func (*TSerializer) Write

func (t *TSerializer) Write(ctx context.Context, msg TStruct) (b []byte, err error)

func (*TSerializer) WriteString

func (t *TSerializer) WriteString(ctx context.Context, msg TStruct) (s string, err error)

type TSerializerPool added in v0.14.0

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

TSerializerPool is the thread-safe version of TSerializer, it uses resource pool of TSerializer under the hood.

It must be initialized with either NewTSerializerPool or NewTSerializerPoolSizeFactory.

func NewTSerializerPool added in v0.14.0

func NewTSerializerPool(f func() *TSerializer) *TSerializerPool

NewTSerializerPool creates a new TSerializerPool.

NewTSerializer can be used as the arg here.

func NewTSerializerPoolSizeFactory added in v0.14.0

func NewTSerializerPoolSizeFactory(size int, factory TProtocolFactory) *TSerializerPool

NewTSerializerPoolSizeFactory creates a new TSerializerPool with the given size and protocol factory.

Note that the size is not the limit. The TMemoryBuffer underneath can grow larger than that. It just dictates the initial size.

func (*TSerializerPool) Write added in v0.14.0

func (t *TSerializerPool) Write(ctx context.Context, msg TStruct) ([]byte, error)

func (*TSerializerPool) WriteString added in v0.14.0

func (t *TSerializerPool) WriteString(ctx context.Context, msg TStruct) (string, error)

type TServer

type TServer interface {
	ProcessorFactory() TProcessorFactory
	ServerTransport() TServerTransport
	InputTransportFactory() TTransportFactory
	OutputTransportFactory() TTransportFactory
	InputProtocolFactory() TProtocolFactory
	OutputProtocolFactory() TProtocolFactory

	// Starts the server
	Serve() error
	// Stops the server. This is optional on a per-implementation basis. Not
	// all servers are required to be cleanly stoppable.
	Stop() error
}

type TServerSocket

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

func NewTServerSocket

func NewTServerSocket(listenAddr string) (*TServerSocket, error)

func NewTServerSocketFromAddrTimeout

func NewTServerSocketFromAddrTimeout(addr net.Addr, clientTimeout time.Duration) *TServerSocket

Creates a TServerSocket from a net.Addr

func NewTServerSocketTimeout

func NewTServerSocketTimeout(listenAddr string, clientTimeout time.Duration) (*TServerSocket, error)

func (*TServerSocket) Accept

func (p *TServerSocket) Accept() (TTransport, error)

func (*TServerSocket) Addr

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

func (*TServerSocket) Close

func (p *TServerSocket) Close() error

func (*TServerSocket) Interrupt

func (p *TServerSocket) Interrupt() error

func (*TServerSocket) IsListening

func (p *TServerSocket) IsListening() bool

Checks whether the socket is listening.

func (*TServerSocket) Listen

func (p *TServerSocket) Listen() error

func (*TServerSocket) Open

func (p *TServerSocket) Open() error

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

type TServerTransport

type TServerTransport interface {
	Listen() error
	Accept() (TTransport, 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 TServerTransport
	// methods.
	Interrupt() error
}

Server transport. Object which provides client transports.

type TSimpleJSONProtocol

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

Simple 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 TJSONProtocol.

func NewTSimpleJSONProtocol deprecated

func NewTSimpleJSONProtocol(t TTransport) *TSimpleJSONProtocol

Deprecated: Use NewTSimpleJSONProtocolConf instead.:

func NewTSimpleJSONProtocolConf added in v0.14.2

func NewTSimpleJSONProtocolConf(t TTransport, conf *TConfiguration) *TSimpleJSONProtocol

func (*TSimpleJSONProtocol) Flush

func (p *TSimpleJSONProtocol) Flush(ctx context.Context) (err error)

func (*TSimpleJSONProtocol) OutputBool

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

func (*TSimpleJSONProtocol) OutputElemListBegin

func (p *TSimpleJSONProtocol) OutputElemListBegin(elemType TType, size int) error

func (*TSimpleJSONProtocol) OutputF64

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

func (*TSimpleJSONProtocol) OutputI64

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

func (*TSimpleJSONProtocol) OutputListBegin

func (p *TSimpleJSONProtocol) OutputListBegin() error

func (*TSimpleJSONProtocol) OutputListEnd

func (p *TSimpleJSONProtocol) OutputListEnd() error

func (*TSimpleJSONProtocol) OutputNull

func (p *TSimpleJSONProtocol) OutputNull() error

func (*TSimpleJSONProtocol) OutputObjectBegin

func (p *TSimpleJSONProtocol) OutputObjectBegin() error

func (*TSimpleJSONProtocol) OutputObjectEnd

func (p *TSimpleJSONProtocol) OutputObjectEnd() error

func (*TSimpleJSONProtocol) OutputPostValue

func (p *TSimpleJSONProtocol) OutputPostValue() error

func (*TSimpleJSONProtocol) OutputPreValue

func (p *TSimpleJSONProtocol) OutputPreValue() error

func (*TSimpleJSONProtocol) OutputString

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

func (*TSimpleJSONProtocol) OutputStringData

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

func (*TSimpleJSONProtocol) ParseBase64EncodedBody

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

func (*TSimpleJSONProtocol) ParseElemListBegin

func (p *TSimpleJSONProtocol) ParseElemListBegin() (elemType TType, size int, e error)

func (*TSimpleJSONProtocol) ParseF64

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

func (*TSimpleJSONProtocol) ParseI64

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

func (*TSimpleJSONProtocol) ParseListBegin

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

func (*TSimpleJSONProtocol) ParseListEnd

func (p *TSimpleJSONProtocol) ParseListEnd() error

func (*TSimpleJSONProtocol) ParseObjectEnd

func (p *TSimpleJSONProtocol) ParseObjectEnd() error

func (*TSimpleJSONProtocol) ParseObjectStart

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

func (*TSimpleJSONProtocol) ParsePostValue

func (p *TSimpleJSONProtocol) ParsePostValue() error

func (*TSimpleJSONProtocol) ParsePreValue

func (p *TSimpleJSONProtocol) ParsePreValue() error

func (*TSimpleJSONProtocol) ParseQuotedStringBody

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

func (*TSimpleJSONProtocol) ParseStringBody

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

func (*TSimpleJSONProtocol) ReadBinary

func (p *TSimpleJSONProtocol) ReadBinary(ctx context.Context) ([]byte, error)

func (*TSimpleJSONProtocol) ReadBool

func (p *TSimpleJSONProtocol) ReadBool(ctx context.Context) (bool, error)

func (*TSimpleJSONProtocol) ReadByte

func (p *TSimpleJSONProtocol) ReadByte(ctx context.Context) (int8, error)

func (*TSimpleJSONProtocol) ReadDouble

func (p *TSimpleJSONProtocol) ReadDouble(ctx context.Context) (float64, error)

func (*TSimpleJSONProtocol) ReadFieldBegin

func (p *TSimpleJSONProtocol) ReadFieldBegin(ctx context.Context) (string, TType, int16, error)

func (*TSimpleJSONProtocol) ReadFieldEnd

func (p *TSimpleJSONProtocol) ReadFieldEnd(ctx context.Context) error

func (*TSimpleJSONProtocol) ReadI16

func (p *TSimpleJSONProtocol) ReadI16(ctx context.Context) (int16, error)

func (*TSimpleJSONProtocol) ReadI32

func (p *TSimpleJSONProtocol) ReadI32(ctx context.Context) (int32, error)

func (*TSimpleJSONProtocol) ReadI64

func (p *TSimpleJSONProtocol) ReadI64(ctx context.Context) (int64, error)

func (*TSimpleJSONProtocol) ReadListBegin

func (p *TSimpleJSONProtocol) ReadListBegin(ctx context.Context) (elemType TType, size int, e error)

func (*TSimpleJSONProtocol) ReadListEnd

func (p *TSimpleJSONProtocol) ReadListEnd(ctx context.Context) error

func (*TSimpleJSONProtocol) ReadMapBegin

func (p *TSimpleJSONProtocol) ReadMapBegin(ctx context.Context) (keyType TType, valueType TType, size int, e error)

func (*TSimpleJSONProtocol) ReadMapEnd

func (p *TSimpleJSONProtocol) ReadMapEnd(ctx context.Context) error

func (*TSimpleJSONProtocol) ReadMessageBegin

func (p *TSimpleJSONProtocol) ReadMessageBegin(ctx context.Context) (name string, typeId TMessageType, seqId int32, err error)

Reading methods.

func (*TSimpleJSONProtocol) ReadMessageEnd

func (p *TSimpleJSONProtocol) ReadMessageEnd(ctx context.Context) error

func (*TSimpleJSONProtocol) ReadSetBegin

func (p *TSimpleJSONProtocol) ReadSetBegin(ctx context.Context) (elemType TType, size int, e error)

func (*TSimpleJSONProtocol) ReadSetEnd

func (p *TSimpleJSONProtocol) ReadSetEnd(ctx context.Context) error

func (*TSimpleJSONProtocol) ReadString

func (p *TSimpleJSONProtocol) ReadString(ctx context.Context) (string, error)

func (*TSimpleJSONProtocol) ReadStructBegin

func (p *TSimpleJSONProtocol) ReadStructBegin(ctx context.Context) (name string, err error)

func (*TSimpleJSONProtocol) ReadStructEnd

func (p *TSimpleJSONProtocol) ReadStructEnd(ctx context.Context) error

func (*TSimpleJSONProtocol) ReadUUID added in v0.18.0

func (p *TSimpleJSONProtocol) ReadUUID(ctx context.Context) (v Tuuid, err error)

func (*TSimpleJSONProtocol) Reset added in v0.17.0

func (p *TSimpleJSONProtocol) Reset()

Reset resets this protocol's internal state.

It's useful when a single protocol instance is reused after errors, to make sure the next use will not be in a bad state to begin with. An example is when it's used in serializer/deserializer pools.

func (*TSimpleJSONProtocol) SetTConfiguration added in v0.14.0

func (p *TSimpleJSONProtocol) SetTConfiguration(conf *TConfiguration)

SetTConfiguration implements TConfigurationSetter for propagation.

func (*TSimpleJSONProtocol) Skip

func (p *TSimpleJSONProtocol) Skip(ctx context.Context, fieldType TType) (err error)

func (*TSimpleJSONProtocol) Transport

func (p *TSimpleJSONProtocol) Transport() TTransport

func (*TSimpleJSONProtocol) WriteBinary

func (p *TSimpleJSONProtocol) WriteBinary(ctx context.Context, v []byte) error

func (*TSimpleJSONProtocol) WriteBool

func (p *TSimpleJSONProtocol) WriteBool(ctx context.Context, b bool) error

func (*TSimpleJSONProtocol) WriteByte

func (p *TSimpleJSONProtocol) WriteByte(ctx context.Context, b int8) error

func (*TSimpleJSONProtocol) WriteDouble

func (p *TSimpleJSONProtocol) WriteDouble(ctx context.Context, v float64) error

func (*TSimpleJSONProtocol) WriteFieldBegin

func (p *TSimpleJSONProtocol) WriteFieldBegin(ctx context.Context, name string, typeId TType, id int16) error

func (*TSimpleJSONProtocol) WriteFieldEnd

func (p *TSimpleJSONProtocol) WriteFieldEnd(ctx context.Context) error

func (*TSimpleJSONProtocol) WriteFieldStop

func (p *TSimpleJSONProtocol) WriteFieldStop(ctx context.Context) error

func (*TSimpleJSONProtocol) WriteI16

func (p *TSimpleJSONProtocol) WriteI16(ctx context.Context, v int16) error

func (*TSimpleJSONProtocol) WriteI32

func (p *TSimpleJSONProtocol) WriteI32(ctx context.Context, v int32) error

func (*TSimpleJSONProtocol) WriteI64

func (p *TSimpleJSONProtocol) WriteI64(ctx context.Context, v int64) error

func (*TSimpleJSONProtocol) WriteListBegin

func (p *TSimpleJSONProtocol) WriteListBegin(ctx context.Context, elemType TType, size int) error

func (*TSimpleJSONProtocol) WriteListEnd

func (p *TSimpleJSONProtocol) WriteListEnd(ctx context.Context) error

func (*TSimpleJSONProtocol) WriteMapBegin

func (p *TSimpleJSONProtocol) WriteMapBegin(ctx context.Context, keyType TType, valueType TType, size int) error

func (*TSimpleJSONProtocol) WriteMapEnd

func (p *TSimpleJSONProtocol) WriteMapEnd(ctx context.Context) error

func (*TSimpleJSONProtocol) WriteMessageBegin

func (p *TSimpleJSONProtocol) WriteMessageBegin(ctx context.Context, name string, typeId TMessageType, seqId int32) error

func (*TSimpleJSONProtocol) WriteMessageEnd

func (p *TSimpleJSONProtocol) WriteMessageEnd(ctx context.Context) error

func (*TSimpleJSONProtocol) WriteSetBegin

func (p *TSimpleJSONProtocol) WriteSetBegin(ctx context.Context, elemType TType, size int) error

func (*TSimpleJSONProtocol) WriteSetEnd

func (p *TSimpleJSONProtocol) WriteSetEnd(ctx context.Context) error

func (*TSimpleJSONProtocol) WriteString

func (p *TSimpleJSONProtocol) WriteString(ctx context.Context, v string) error

func (*TSimpleJSONProtocol) WriteStructBegin

func (p *TSimpleJSONProtocol) WriteStructBegin(ctx context.Context, name string) error

func (*TSimpleJSONProtocol) WriteStructEnd

func (p *TSimpleJSONProtocol) WriteStructEnd(ctx context.Context) error

func (*TSimpleJSONProtocol) WriteUUID added in v0.18.0

func (p *TSimpleJSONProtocol) WriteUUID(ctx context.Context, v Tuuid) error

type TSimpleJSONProtocolFactory

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

Factory

func NewTSimpleJSONProtocolFactory deprecated

func NewTSimpleJSONProtocolFactory() *TSimpleJSONProtocolFactory

Deprecated: Use NewTSimpleJSONProtocolFactoryConf instead.

func NewTSimpleJSONProtocolFactoryConf added in v0.14.2

func NewTSimpleJSONProtocolFactoryConf(conf *TConfiguration) *TSimpleJSONProtocolFactory

func (*TSimpleJSONProtocolFactory) GetProtocol

func (p *TSimpleJSONProtocolFactory) GetProtocol(trans TTransport) TProtocol

func (*TSimpleJSONProtocolFactory) SetTConfiguration added in v0.14.2

func (p *TSimpleJSONProtocolFactory) SetTConfiguration(conf *TConfiguration)

SetTConfiguration implements TConfigurationSetter for propagation.

type TSimpleServer

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

* This is not a typical TSimpleServer as it is not blocked after accept a socket. * It is more like a TThreadedServer that can handle different connections in different goroutines. * This will work if golang user implements a conn-pool like thing in client side.

func NewTSimpleServer2

func NewTSimpleServer2(processor TProcessor, serverTransport TServerTransport) *TSimpleServer

func NewTSimpleServer4

func NewTSimpleServer4(processor TProcessor, serverTransport TServerTransport, transportFactory TTransportFactory, protocolFactory TProtocolFactory) *TSimpleServer

func NewTSimpleServer6

func NewTSimpleServer6(processor TProcessor, serverTransport TServerTransport, inputTransportFactory TTransportFactory, outputTransportFactory TTransportFactory, inputProtocolFactory TProtocolFactory, outputProtocolFactory TProtocolFactory) *TSimpleServer

func NewTSimpleServerFactory2

func NewTSimpleServerFactory2(processorFactory TProcessorFactory, serverTransport TServerTransport) *TSimpleServer

func NewTSimpleServerFactory4

func NewTSimpleServerFactory4(processorFactory TProcessorFactory, serverTransport TServerTransport, transportFactory TTransportFactory, protocolFactory TProtocolFactory) *TSimpleServer

func NewTSimpleServerFactory6

func NewTSimpleServerFactory6(processorFactory TProcessorFactory, serverTransport TServerTransport, inputTransportFactory TTransportFactory, outputTransportFactory TTransportFactory, inputProtocolFactory TProtocolFactory, outputProtocolFactory TProtocolFactory) *TSimpleServer

func (*TSimpleServer) AcceptLoop

func (p *TSimpleServer) AcceptLoop() error

func (*TSimpleServer) InputProtocolFactory

func (p *TSimpleServer) InputProtocolFactory() TProtocolFactory

func (*TSimpleServer) InputTransportFactory

func (p *TSimpleServer) InputTransportFactory() TTransportFactory

func (*TSimpleServer) Listen

func (p *TSimpleServer) Listen() error

func (*TSimpleServer) OutputProtocolFactory

func (p *TSimpleServer) OutputProtocolFactory() TProtocolFactory

func (*TSimpleServer) OutputTransportFactory

func (p *TSimpleServer) OutputTransportFactory() TTransportFactory

func (*TSimpleServer) ProcessorFactory

func (p *TSimpleServer) ProcessorFactory() TProcessorFactory

func (*TSimpleServer) Serve

func (p *TSimpleServer) Serve() error

func (*TSimpleServer) ServerTransport

func (p *TSimpleServer) ServerTransport() TServerTransport

func (*TSimpleServer) SetForwardHeaders added in v0.13.0

func (p *TSimpleServer) SetForwardHeaders(headers []string)

SetForwardHeaders sets the list of header keys that will be auto forwarded while using THeaderProtocol.

"forward" means that when the server is also a client to other upstream thrift servers, the context object user gets in the processor functions will have both read and write headers set, with write headers being forwarded. Users can always override the write headers by calling SetWriteHeaderList before calling thrift client functions.

func (*TSimpleServer) SetLogContext added in v0.20.0

func (p *TSimpleServer) SetLogContext(ctx context.Context)

SetLogContext sets the context to be used when logging errors inside TSimpleServer.

If this is not called before calling Serve, context.Background() will be used.

func (*TSimpleServer) SetLogger deprecated added in v0.14.0

func (p *TSimpleServer) SetLogger(_ Logger)

SetLogger sets the logger used by this TSimpleServer.

If no logger was set before Serve is called, a default logger using standard log library will be used.

Deprecated: The logging inside TSimpleServer is now done via slog on error level, this does nothing now. It will be removed in a future version.

func (*TSimpleServer) Stop

func (p *TSimpleServer) Stop() error

type TSocket

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

func NewTSocket deprecated

func NewTSocket(hostPort string) (*TSocket, error)

Deprecated: Use NewTSocketConf instead.

func NewTSocketConf added in<