Code Examples
/*
* 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{})
}
/*
* 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())
}
Package-Level Type Names (total 83)
/* sort by: | */
ClientMiddleware can be passed to WrapClient in order to wrap TClient calls
with custom middleware.
func WrapClient(client TClient, middlewares ...ClientMiddleware) TClient
ProcessorError is the combined original error returned by the endpoint
implementation, and I/O error when writing the response back to the client.
This type will be returned by Process function if there's an error happened
during writing the response back to the client. ProcessorMiddlewares can
check for this type (use errors.As) to get the underlying write and endpoint
errors. EndpointError is the original error returned by the endpoint
implementation, might be nil. WriteError is the error happened during writing the response to the
client, always set.(*ProcessorError) Error() string(*ProcessorError) TExceptionType() TExceptionType(*ProcessorError) Unwrap() []error
*ProcessorError : TException
*ProcessorError : error
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.
func WrapProcessor(processor TProcessor, middlewares ...ProcessorMiddleware) TProcessor
SlogTStructWrapper is a wrapper used by the compiler to wrap TStruct and
TException to be better logged by slog.TypestringValueTStruct( SlogTStructWrapper) MarshalJSON() ([]byte, error)( SlogTStructWrapper) String() string
SlogTStructWrapper : github.com/goccy/go-json.Marshaler
SlogTStructWrapper : encoding/json.Marshaler
SlogTStructWrapper : expvar.Var
SlogTStructWrapper : fmt.Stringer
ReadWriterbufio.ReadWriterReadWriter.Reader*bufio.ReaderReadWriter.Writer*bufio.Writer Available returns how many bytes are unused in the buffer. AvailableBuffer returns an empty buffer with b.Available() capacity.
This buffer is intended to be appended to and
passed to an immediately succeeding [Writer.Write] call.
The buffer is only valid until the next write operation on b.(*TBufferedTransport) Close() (err error) Discard skips the next n bytes, returning the number of bytes discarded.
If Discard skips fewer than n bytes, it also returns an error.
If 0 <= n <= b.Buffered(), Discard is guaranteed to succeed without
reading from the underlying io.Reader.(*TBufferedTransport) Flush(ctx context.Context) error(*TBufferedTransport) IsOpen() bool(*TBufferedTransport) Open() (err error) Peek returns the next n bytes without advancing the reader. The bytes stop
being valid at the next read call. If necessary, Peek will read more bytes
into the buffer in order to make n bytes available. If Peek returns fewer
than n bytes, it also returns an error explaining why the read is short.
The error is [ErrBufferFull] if n is larger than b's buffer size.
Calling Peek prevents a [Reader.UnreadByte] or [Reader.UnreadRune] call from succeeding
until the next read operation.(*TBufferedTransport) Read(b []byte) (int, error) ReadByte reads and returns a single byte.
If no byte is available, returns an error. ReadBytes reads until the first occurrence of delim in the input,
returning a slice containing the data up to and including the delimiter.
If ReadBytes encounters an error before finding a delimiter,
it returns the data read before the error and the error itself (often io.EOF).
ReadBytes returns err != nil if and only if the returned data does not end in
delim.
For simple uses, a Scanner may be more convenient. ReadFrom implements [io.ReaderFrom]. If the underlying writer
supports the ReadFrom method, this calls the underlying ReadFrom.
If there is buffered data and an underlying ReadFrom, this fills
the buffer and writes it before calling ReadFrom. ReadLine is a low-level line-reading primitive. Most callers should use
[Reader.ReadBytes]('\n') or [Reader.ReadString]('\n') instead or use a [Scanner].
ReadLine tries to return a single line, not including the end-of-line bytes.
If the line was too long for the buffer then isPrefix is set and the
beginning of the line is returned. The rest of the line will be returned
from future calls. isPrefix will be false when returning the last fragment
of the line. The returned buffer is only valid until the next call to
ReadLine. ReadLine either returns a non-nil line or it returns an error,
never both.
The text returned from ReadLine does not include the line end ("\r\n" or "\n").
No indication or error is given if the input ends without a final line end.
Calling [Reader.UnreadByte] after ReadLine will always unread the last byte read
(possibly a character belonging to the line end) even if that byte is not
part of the line returned by ReadLine. ReadRune reads a single UTF-8 encoded Unicode character and returns the
rune and its size in bytes. If the encoded rune is invalid, it consumes one byte
and returns unicode.ReplacementChar (U+FFFD) with a size of 1. ReadSlice reads until the first occurrence of delim in the input,
returning a slice pointing at the bytes in the buffer.
The bytes stop being valid at the next read.
If ReadSlice encounters an error before finding a delimiter,
it returns all the data in the buffer and the error itself (often io.EOF).
ReadSlice fails with error [ErrBufferFull] if the buffer fills without a delim.
Because the data returned from ReadSlice will be overwritten
by the next I/O operation, most clients should use
[Reader.ReadBytes] or ReadString instead.
ReadSlice returns err != nil if and only if line does not end in delim. ReadString reads until the first occurrence of delim in the input,
returning a string containing the data up to and including the delimiter.
If ReadString encounters an error before finding a delimiter,
it returns the data read before the error and the error itself (often io.EOF).
ReadString returns err != nil if and only if the returned data does not end in
delim.
For simple uses, a Scanner may be more convenient.(*TBufferedTransport) RemainingBytes() (num_bytes uint64) SetTConfiguration implements TConfigurationSetter for propagation. UnreadByte unreads the last byte. Only the most recently read byte can be unread.
UnreadByte returns an error if the most recent method called on the
[Reader] was not a read operation. Notably, [Reader.Peek], [Reader.Discard], and [Reader.WriteTo] are not
considered read operations. UnreadRune unreads the last rune. If the most recent method called on
the [Reader] was not a [Reader.ReadRune], [Reader.UnreadRune] returns an error. (In this
regard it is stricter than [Reader.UnreadByte], which will unread the last byte
from any read operation.)(*TBufferedTransport) Write(b []byte) (int, error) WriteByte writes a single byte. WriteRune writes a single Unicode code point, returning
the number of bytes written and any error. WriteString writes a string.
It returns the number of bytes written.
If the count is less than len(s), it also returns an error explaining
why the write is short. WriteTo implements io.WriterTo.
This may make multiple calls to the [Reader.Read] method of the underlying [Reader].
If the underlying reader supports the [Reader.WriteTo] method,
this calls the underlying [Reader.WriteTo] without buffering.
*TBufferedTransport : ContextFlusher
*TBufferedTransport : ReadSizeProvider
*TBufferedTransport : TConfigurationSetter
*TBufferedTransport : TRichTransport
*TBufferedTransport : TTransport
TBufferedTransport : github.com/gobwas/ws.HandshakeHeader
*TBufferedTransport : github.com/klauspost/compress/flate.Reader
*TBufferedTransport : github.com/miekg/dns.Writer
*TBufferedTransport : github.com/pion/stun.Connection
*TBufferedTransport : github.com/pion/stun/v3.Connection
*TBufferedTransport : github.com/prometheus/common/expfmt.Closer
*TBufferedTransport : github.com/quic-go/quic-go/quicvarint.Reader
*TBufferedTransport : github.com/quic-go/quic-go/quicvarint.Writer
*TBufferedTransport : compress/flate.Reader
*TBufferedTransport : google.golang.org/protobuf/encoding/protodelim.Reader
TBufferedTransport : gorm.io/gorm/clause.Writer
*TBufferedTransport : internal/bisect.Writer
TBufferedTransport : io.ByteReader
TBufferedTransport : io.ByteScanner
TBufferedTransport : io.ByteWriter
*TBufferedTransport : io.Closer
*TBufferedTransport : io.ReadCloser
*TBufferedTransport : io.Reader
TBufferedTransport : io.ReaderFrom
*TBufferedTransport : io.ReadWriteCloser
*TBufferedTransport : io.ReadWriter
TBufferedTransport : io.RuneReader
TBufferedTransport : io.RuneScanner
TBufferedTransport : io.StringWriter
*TBufferedTransport : io.WriteCloser
*TBufferedTransport : io.Writer
TBufferedTransport : io.WriterTo
func NewTBufferedTransport(trans TTransport, bufferSize int) *TBufferedTransport
(*TCompactProtocol) Flush(ctx context.Context) (err error) Read a []byte from the wire. 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. Read a single byte off the wire. Nothing interesting here. No magic here - just read a double off the wire. Read a field header off the wire.(*TCompactProtocol) ReadFieldEnd(ctx context.Context) error Read an i16 from the wire as a zigzag varint. Read an i32 from the wire as a zigzag varint. Read an i64 from the wire as a zigzag varint. 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.(*TCompactProtocol) ReadListEnd(ctx context.Context) 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.(*TCompactProtocol) ReadMapEnd(ctx context.Context) error Read a message header.(*TCompactProtocol) ReadMessageEnd(ctx context.Context) 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.(*TCompactProtocol) ReadSetEnd(ctx context.Context) error Reads a []byte (via readBinary), and then UTF-8 decodes it. 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. Doesn't actually consume any wire data, just removes the last field for
this struct from the field stack. Read fixed 16 bytes as UUID.(*TCompactProtocol) SetTConfiguration(conf *TConfiguration)(*TCompactProtocol) Skip(ctx context.Context, fieldType TType) (err error)(*TCompactProtocol) Transport() TTransport Write a byte array, using a varint for the size.(*TCompactProtocol) WriteBool(ctx context.Context, value bool) error Write a byte. Nothing to see here! Write a double to the wire as 8 bytes.(*TCompactProtocol) WriteFieldBegin(ctx context.Context, name string, typeId TType, id int16) error(*TCompactProtocol) WriteFieldEnd(ctx context.Context) error(*TCompactProtocol) WriteFieldStop(ctx context.Context) error Write an I16 as a zigzag varint. Write an i32 as a zigzag varint. Write an i64 as a zigzag varint. Write a list header.(*TCompactProtocol) WriteListEnd(ctx context.Context) error(*TCompactProtocol) WriteMapBegin(ctx context.Context, keyType TType, valueType TType, size int) error(*TCompactProtocol) WriteMapEnd(ctx context.Context) 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.(*TCompactProtocol) WriteMessageEnd(ctx context.Context) error Write a set header.(*TCompactProtocol) WriteSetEnd(ctx context.Context) error Write a string to the wire with a varint size preceding. 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. 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. Write a Tuuid to the wire as 16 bytes.
*TCompactProtocol : ContextFlusher
*TCompactProtocol : TConfigurationSetter
*TCompactProtocol : TProtocol
func NewTCompactProtocol(trans TTransport) *TCompactProtocol
func NewTCompactProtocolConf(trans TTransport, conf *TConfiguration) *TCompactProtocol
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) 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. If <= 0, DEFAULT_MAX_FRAME_SIZE will be used instead.
Also if MaxMessageSize < MaxFrameSize,
MaxMessageSize will be used instead. If <= 0, DEFAULT_MAX_MESSAGE_SIZE will be used instead.SocketTimeouttime.Duration Strict read/write configurations for TBinaryProtocol.
BoolPtr helper function is available to use literal values.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. The write transforms to be applied to THeaderTransport. TLS config to be used by TSSLSocket. 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. 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. 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. 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. 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. 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. 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. 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). GetTLSConfig returns the tls config should be used by TSSLSocket.
It's nil-safe. If tc is nil, nil will be returned instead.
func NewTBinaryProtocolConf(t TTransport, conf *TConfiguration) *TBinaryProtocol
func NewTBinaryProtocolFactoryConf(conf *TConfiguration) *TBinaryProtocolFactory
func NewTCompactProtocolConf(trans TTransport, conf *TConfiguration) *TCompactProtocol
func NewTCompactProtocolFactoryConf(conf *TConfiguration) *TCompactProtocolFactory
func NewTFramedTransportConf(transport TTransport, conf *TConfiguration) *TFramedTransport
func NewTFramedTransportFactoryConf(factory TTransportFactory, conf *TConfiguration) TTransportFactory
func NewTHeaderProtocolConf(trans TTransport, conf *TConfiguration) *THeaderProtocol
func NewTHeaderProtocolFactoryConf(conf *TConfiguration) TProtocolFactory
func NewTHeaderTransportConf(trans TTransport, conf *TConfiguration) *THeaderTransport
func NewTHeaderTransportFactoryConf(factory TTransportFactory, conf *TConfiguration) TTransportFactory
func NewTSimpleJSONProtocolConf(t TTransport, conf *TConfiguration) *TSimpleJSONProtocol
func NewTSimpleJSONProtocolFactoryConf(conf *TConfiguration) *TSimpleJSONProtocolFactory
func NewTSocketConf(hostPort string, conf *TConfiguration) *TSocket
func NewTSocketFromAddrConf(addr net.Addr, conf *TConfiguration) *TSocket
func NewTSocketFromConnConf(conn net.Conn, conf *TConfiguration) *TSocket
func NewTSSLSocketConf(hostPort string, conf *TConfiguration) *TSSLSocket
func NewTSSLSocketFromAddrConf(addr net.Addr, conf *TConfiguration) *TSSLSocket
func NewTSSLSocketFromConnConf(conn net.Conn, conf *TConfiguration) *TSSLSocket
func PropagateTConfiguration(impl interface{}, cfg *TConfiguration)
func TProtocolFactoryConf(delegate TProtocolFactory, conf *TConfiguration) TProtocolFactory
func TTransportFactoryConf(delegate TTransportFactory, conf *TConfiguration) TTransportFactory
func (*StreamTransport).SetTConfiguration(conf *TConfiguration)
func (*TBinaryProtocol).SetTConfiguration(conf *TConfiguration)
func (*TBinaryProtocolFactory).SetTConfiguration(conf *TConfiguration)
func (*TBufferedTransport).SetTConfiguration(conf *TConfiguration)
func (*TCompactProtocol).SetTConfiguration(conf *TConfiguration)
func (*TCompactProtocolFactory).SetTConfiguration(conf *TConfiguration)
func TConfigurationSetter.SetTConfiguration(*TConfiguration)
func (*TDebugProtocol).SetTConfiguration(conf *TConfiguration)
func (*TDuplicateToProtocol).SetTConfiguration(conf *TConfiguration)
func (*TFramedTransport).SetTConfiguration(cfg *TConfiguration)
func (*THeaderProtocol).SetTConfiguration(cfg *TConfiguration)
func (*THeaderTransport).SetTConfiguration(cfg *TConfiguration)
func (*THeaderTransportFactory).SetTConfiguration(cfg *TConfiguration)
func (*TSimpleJSONProtocol).SetTConfiguration(conf *TConfiguration)
func (*TSimpleJSONProtocolFactory).SetTConfiguration(conf *TConfiguration)
func (*TSocket).SetTConfiguration(conf *TConfiguration)
func (*TSSLSocket).SetTConfiguration(conf *TConfiguration)
func (*TZlibTransport).SetTConfiguration(conf *TConfiguration)
THeaderResponseHelper defines THeader related TResponseHelper functions.
The zero value of *THeaderResponseHelper is valid with all helper functions
being no-op. ClearHeaders clears all the response headers previously set.
It's no-op if the underlying protocol/transport does not support THeader. SetHeader sets a response header.
It's no-op if the underlying protocol/transport does not support THeader.
func NewTHeaderResponseHelper(proto TProtocol) *THeaderResponseHelper
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.Flagsuint32SequenceIDint32 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. ClearWriteHeaders clears all write headers previously set. Close closes the transport, along with its underlying transport. Flush writes the appropriate header and the write buffer to the underlying transport. GetReadHeaders returns the THeaderMap read from transport. IsOpen calls the underlying transport's IsOpen function. Open calls the underlying transport's Open function. Protocol returns the wrapped protocol id used in this THeaderTransport.(*THeaderTransport) Read(p []byte) (read int, err error) ReadFrame tries to read the frame header, guess the client type, and handle
unframed clients. 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. SetTConfiguration implements TConfigurationSetter. SetWriteHeader sets a header for write. Write writes data to the write buffer.
You need to call Flush to actually write them to the transport.
*THeaderTransport : ContextFlusher
*THeaderTransport : ReadSizeProvider
*THeaderTransport : TConfigurationSetter
*THeaderTransport : TTransport
*THeaderTransport : github.com/miekg/dns.Writer
*THeaderTransport : github.com/pion/stun.Connection
*THeaderTransport : github.com/pion/stun/v3.Connection
*THeaderTransport : github.com/prometheus/common/expfmt.Closer
*THeaderTransport : internal/bisect.Writer
*THeaderTransport : io.Closer
*THeaderTransport : io.ReadCloser
*THeaderTransport : io.Reader
*THeaderTransport : io.ReadWriteCloser
*THeaderTransport : io.ReadWriter
*THeaderTransport : io.WriteCloser
*THeaderTransport : io.Writer
func NewTHeaderTransport(trans TTransport) *THeaderTransport
func NewTHeaderTransportConf(trans TTransport, conf *TConfiguration) *THeaderTransport
THeaderTransportFactory is a TTransportFactory implementation to create
THeaderTransport.
It also implements TConfigurationSetter. The underlying factory, could be nil. GetTransport implements TTransportFactory. SetTConfiguration implements TConfigurationSetter.
*THeaderTransportFactory : TConfigurationSetter
*THeaderTransportFactory : TTransportFactory
(*THttpClient) Close() error 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")(*THttpClient) Flush(ctx context.Context) error 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")(*THttpClient) IsOpen() bool(*THttpClient) Open() error(*THttpClient) Read(buf []byte) (int, error)(*THttpClient) ReadByte() (c byte, err error)(*THttpClient) RemainingBytes() (num_bytes uint64) 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")(*THttpClient) Write(buf []byte) (int, error)(*THttpClient) WriteByte(c byte) error(*THttpClient) WriteString(s string) (n int, err error)
*THttpClient : ContextFlusher
*THttpClient : ReadSizeProvider
*THttpClient : TRichTransport
*THttpClient : TTransport
*THttpClient : github.com/klauspost/compress/flate.Reader
*THttpClient : github.com/miekg/dns.Writer
*THttpClient : github.com/pion/stun.Connection
*THttpClient : github.com/pion/stun/v3.Connection
*THttpClient : github.com/prometheus/common/expfmt.Closer
*THttpClient : github.com/quic-go/quic-go/quicvarint.Reader
*THttpClient : github.com/quic-go/quic-go/quicvarint.Writer
*THttpClient : compress/flate.Reader
*THttpClient : google.golang.org/protobuf/encoding/protodelim.Reader
*THttpClient : gorm.io/gorm/clause.Writer
*THttpClient : internal/bisect.Writer
*THttpClient : io.ByteReader
*THttpClient : io.ByteWriter
*THttpClient : io.Closer
*THttpClient : io.ReadCloser
*THttpClient : io.Reader
*THttpClient : io.ReadWriteCloser
*THttpClient : io.ReadWriter
*THttpClient : io.StringWriter
*THttpClient : io.WriteCloser
*THttpClient : io.Writer
Memory buffer-based implementation of the TTransport interface.Buffer*bytes.Buffer Available returns how many bytes are unused in the buffer. AvailableBuffer returns an empty buffer with b.Available() capacity.
This buffer is intended to be appended to and
passed to an immediately succeeding [Buffer.Write] call.
The buffer is only valid until the next write operation on b. Bytes returns a slice of length b.Len() holding the unread portion of the buffer.
The slice is valid for use only until the next buffer modification (that is,
only until the next call to a method like [Buffer.Read], [Buffer.Write], [Buffer.Reset], or [Buffer.Truncate]).
The slice aliases the buffer content at least until the next buffer modification,
so immediate changes to the slice will affect the result of future reads. Cap returns the capacity of the buffer's underlying byte slice, that is, the
total space allocated for the buffer's data.(*TMemoryBuffer) Close() error Flushing a memory buffer is a no-op Grow grows the buffer's capacity, if necessary, to guarantee space for
another n bytes. After Grow(n), at least n bytes can be written to the
buffer without another allocation.
If n is negative, Grow will panic.
If the buffer can't grow it will panic with [ErrTooLarge].(*TMemoryBuffer) IsOpen() bool Len returns the number of bytes of the unread portion of the buffer;
b.Len() == len(b.Bytes()). Next returns a slice containing the next n bytes from the buffer,
advancing the buffer as if the bytes had been returned by [Buffer.Read].
If there are fewer than n bytes in the buffer, Next returns the entire buffer.
The slice is only valid until the next call to a read or write method.(*TMemoryBuffer) Open() error Read reads the next len(p) bytes from the buffer or until the buffer
is drained. The return value n is the number of bytes read. If the
buffer has no data to return, err is [io.EOF] (unless len(p) is zero);
otherwise it is nil. ReadByte reads and returns the next byte from the buffer.
If no byte is available, it returns error [io.EOF]. ReadBytes reads until the first occurrence of delim in the input,
returning a slice containing the data up to and including the delimiter.
If ReadBytes encounters an error before finding a delimiter,
it returns the data read before the error and the error itself (often [io.EOF]).
ReadBytes returns err != nil if and only if the returned data does not end in
delim. ReadFrom reads data from r until EOF and appends it to the buffer, growing
the buffer as needed. The return value n is the number of bytes read. Any
error except io.EOF encountered during the read is also returned. If the
buffer becomes too large, ReadFrom will panic with [ErrTooLarge]. ReadRune reads and returns the next UTF-8-encoded
Unicode code point from the buffer.
If no bytes are available, the error returned is io.EOF.
If the bytes are an erroneous UTF-8 encoding, it
consumes one byte and returns U+FFFD, 1. ReadString reads until the first occurrence of delim in the input,
returning a string containing the data up to and including the delimiter.
If ReadString encounters an error before finding a delimiter,
it returns the data read before the error and the error itself (often [io.EOF]).
ReadString returns err != nil if and only if the returned data does not end
in delim.(*TMemoryBuffer) RemainingBytes() (num_bytes uint64) Reset resets the buffer to be empty,
but it retains the underlying storage for use by future writes.
Reset is the same as [Buffer.Truncate](0). String returns the contents of the unread portion of the buffer
as a string. If the [Buffer] is a nil pointer, it returns "<nil>".
To build strings more efficiently, see the [strings.Builder] type. Truncate discards all but the first n unread bytes from the buffer
but continues to use the same allocated storage.
It panics if n is negative or greater than the length of the buffer. UnreadByte unreads the last byte returned by the most recent successful
read operation that read at least one byte. If a write has happened since
the last read, if the last read returned an error, or if the read read zero
bytes, UnreadByte returns an error. UnreadRune unreads the last rune returned by [Buffer.ReadRune].
If the most recent read or write operation on the buffer was
not a successful [Buffer.ReadRune], UnreadRune returns an error. (In this regard
it is stricter than [Buffer.UnreadByte], which will unread the last byte
from any read operation.) Write appends the contents of p to the buffer, growing the buffer as
needed. The return value n is the length of p; err is always nil. If the
buffer becomes too large, Write will panic with [ErrTooLarge]. WriteByte appends the byte c to the buffer, growing the buffer as needed.
The returned error is always nil, but is included to match [bufio.Writer]'s
WriteByte. If the buffer becomes too large, WriteByte will panic with
[ErrTooLarge]. WriteRune appends the UTF-8 encoding of Unicode code point r to the
buffer, returning its length and an error, which is always nil but is
included to match [bufio.Writer]'s WriteRune. The buffer is grown as needed;
if it becomes too large, WriteRune will panic with [ErrTooLarge]. WriteString appends the contents of s to the buffer, growing the buffer as
needed. The return value n is the length of s; err is always nil. If the
buffer becomes too large, WriteString will panic with [ErrTooLarge]. WriteTo writes data to w until the buffer is drained or an error occurs.
The return value n is the number of bytes written; it always fits into an
int, but it is int64 to match the [io.WriterTo] interface. Any error
encountered during the write is also returned.
*TMemoryBuffer : ContextFlusher
*TMemoryBuffer : ReadSizeProvider
*TMemoryBuffer : TRichTransport
*TMemoryBuffer : TTransport
TMemoryBuffer : github.com/apache/arrow-go/v18/internal/hashing.ByteSlice
TMemoryBuffer : github.com/gobwas/ws.HandshakeHeader
TMemoryBuffer : github.com/klauspost/compress/flate.Reader
TMemoryBuffer : github.com/miekg/dns.Writer
*TMemoryBuffer : github.com/pion/stun.Connection
*TMemoryBuffer : github.com/pion/stun/v3.Connection
*TMemoryBuffer : github.com/prometheus/common/expfmt.Closer
TMemoryBuffer : github.com/quic-go/quic-go/quicvarint.Reader
TMemoryBuffer : github.com/quic-go/quic-go/quicvarint.Writer
TMemoryBuffer : compress/flate.Reader
TMemoryBuffer : expvar.Var
TMemoryBuffer : fmt.Stringer
TMemoryBuffer : google.golang.org/protobuf/encoding/protodelim.Reader
TMemoryBuffer : gorm.io/gorm/clause.Writer
TMemoryBuffer : internal/bisect.Writer
TMemoryBuffer : io.ByteReader
TMemoryBuffer : io.ByteScanner
TMemoryBuffer : io.ByteWriter
*TMemoryBuffer : io.Closer
*TMemoryBuffer : io.ReadCloser
TMemoryBuffer : io.Reader
TMemoryBuffer : io.ReaderFrom
*TMemoryBuffer : io.ReadWriteCloser
TMemoryBuffer : io.ReadWriter
TMemoryBuffer : io.RuneReader
TMemoryBuffer : io.RuneScanner
TMemoryBuffer : io.StringWriter
*TMemoryBuffer : io.WriteCloser
TMemoryBuffer : io.Writer
TMemoryBuffer : io.WriterTo
func NewTMemoryBuffer() *TMemoryBuffer
func NewTMemoryBufferLen(size int) *TMemoryBuffer
DefaultProcessorTProcessor 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.(*TMultiplexedProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) 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.(*TMultiplexedProcessor) RegisterDefault(processor TProcessor)(*TMultiplexedProcessor) RegisterProcessor(name string, processor TProcessor)
*TMultiplexedProcessor : TProcessor
func NewTMultiplexedProcessor() *TMultiplexedProcessor
TransformReader is an io.ReadCloser that handles transforms reading.Readerio.Reader AddTransform adds a transform.
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. Close calls the underlying closers in appropriate order,
stops at and returns the first error encountered.( TransformReader) Read(p []byte) (n int, err error)
*TransformReader : github.com/prometheus/common/expfmt.Closer
*TransformReader : io.Closer
*TransformReader : io.ReadCloser
TransformReader : io.Reader
func NewTransformReaderWithCapacity(baseReader io.Reader, capacity int) *TransformReader
TransformWriter is an io.WriteCloser that handles transforms writing.Writerio.Writer AddTransform adds a transform. Close calls the underlying closers in appropriate order,
stops at and returns the first error encountered.( TransformWriter) Write([]byte) (int, error)
TransformWriter : github.com/miekg/dns.Writer
*TransformWriter : github.com/prometheus/common/expfmt.Closer
TransformWriter : internal/bisect.Writer
*TransformWriter : io.Closer
*TransformWriter : io.WriteCloser
TransformWriter : io.Writer
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. THeader related functions ClearHeaders clears all the response headers previously set.
It's no-op if the underlying protocol/transport does not support THeader. SetHeader sets a response header.
It's no-op if the underlying protocol/transport does not support THeader.
func GetResponseHelper(ctx context.Context) (helper TResponseHelper, ok bool)
func SetResponseHelper(ctx context.Context, helper TResponseHelper) context.Context
TZlibTransport is a TTransport implementation that makes use of zlib compression. Close closes the reader and writer (flushing any unwritten data) and closes
the underlying transport. Flush flushes the writer and its underlying transport. IsOpen returns true if the transport is open Open opens the transport for communication(*TZlibTransport) Read(p []byte) (int, error) RemainingBytes returns the size in bytes of the data that is still to be
read. SetTConfiguration implements TConfigurationSetter for propagation.(*TZlibTransport) Write(p []byte) (int, error)
*TZlibTransport : ContextFlusher
*TZlibTransport : ReadSizeProvider
*TZlibTransport : TConfigurationSetter
*TZlibTransport : TTransport
*TZlibTransport : github.com/miekg/dns.Writer
*TZlibTransport : github.com/pion/stun.Connection
*TZlibTransport : github.com/pion/stun/v3.Connection
*TZlibTransport : github.com/prometheus/common/expfmt.Closer
*TZlibTransport : internal/bisect.Writer
*TZlibTransport : io.Closer
*TZlibTransport : io.ReadCloser
*TZlibTransport : io.Reader
*TZlibTransport : io.ReadWriteCloser
*TZlibTransport : io.ReadWriter
*TZlibTransport : io.WriteCloser
*TZlibTransport : io.Writer
func NewTZlibTransport(trans TTransport, level int) (*TZlibTransport, error)
WrappedTClient is a convenience struct that implements the TClient interface
using inner Wrapped function.
This is provided to aid in developing ClientMiddleware.Wrappedfunc(ctx context.Context, method string, args, result TStruct) (ResponseMeta, error) Call implements the TClient interface by calling and returning c.Wrapped.
WrappedTClient : TClient
WrappedTProcessorFunction is a convenience struct that implements the
TProcessorFunction interface that can be used when implementing custom
Middleware. Wrapped is called by WrappedTProcessorFunction.Process and should be a
"wrapped" call to a base TProcessorFunc.Process call. Process implements the TProcessorFunction interface using p.Wrapped.
WrappedTProcessorFunction : TProcessorFunction
Package-Level Functions (total 150)
AddReadTHeaderToContext adds the whole THeader headers into context.
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.
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.
GetHeader returns a value of the given header from the context.
GetReadHeaderList returns the key list of read THeaders from the context.
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.
GetWriteHeaderList returns the key list of THeaders to write from the context.
Type Parameters:
T: any 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"))
NewTDebugProtocolFactory creates a TDebugProtocolFactory.
Deprecated: Please use NewTDebugProtocolFactoryWithLogger or the struct
itself instead. This version will use the default logger from standard
library.
NewTDebugProtocolFactoryWithLogger creates a TDebugProtocolFactory.
NewTDeserializerPool creates a new TDeserializerPool.
NewTDeserializer can be used as the arg here.
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.
Deprecated: Use NewTFramedTransportFactoryConf instead.
Deprecated: Use NewTFramedTransportConf instead.
Deprecated: Use NewTHeaderProtocolConf instead.
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.
Deprecated: Use NewTHeaderProtocolFactoryConf instead.
NewTHeaderProtocolFactoryConf creates a factory for THeader with given
TConfiguration.
NewTHeaderResponseHelper creates a new THeaderResponseHelper from the
underlying TProtocol.
Deprecated: Use NewTHeaderTransportConf instead.
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.
Deprecated: Use NewTHeaderTransportFactoryConf instead.
NewTHeaderTransportFactoryConf creates a new *THeaderTransportFactory with
the given *TConfiguration.
NewThriftHandlerFunc is a function that create a ready to use Apache Thrift Handler function
NewTransformReaderWithCapacity initializes a TransformReader with expected
closers capacity.
If you don't know the closers capacity beforehand, just use
&TransformReader{Reader: baseReader}
instead would be sufficient.
NewTransformWriter creates a new TransformWriter with base writer and transforms.
Wraps Transport to provide TRichTransport interface
NewTSerializerPool creates a new TSerializerPool.
NewTSerializer can be used as the arg here.
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.
NewTSocketConf creates a net.Conn-backed TTransport, given a host and port.
Example:
trans := thrift.NewTSocketConf("localhost:9090", &TConfiguration{
ConnectTimeout: time.Second, // Use 0 for no timeout
SocketTimeout: time.Second, // Use 0 for no timeout
})
NewTSocketFromAddrConf creates a TSocket from a net.Addr
Deprecated: Use NewTSocketFromAddrConf instead.
NewTSocketFromConnConf creates a TSocket from an existing net.Conn.
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.
}
})
NewTSSLSocketFromAddrConf creates a TSSLSocket from a net.Addr.
Deprecated: Use NewTSSLSocketFromAddrConf instead.
NewTSSLSocketFromConnConf creates a TSSLSocket from an existing net.Conn.
Deprecated: Use NewTSSLSocketFromConnConf instead.
Deprecated: Use NewTSSLSocketConf instead.
TStandardClient implements TClient, and uses the standard message format for Thrift.
It is not safe for concurrent use.
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.
ParseTuuid parses a canonical form UUID string into Tuuid.
Note that this function only supports case insensitive canonical form
(8-4-4-4-12/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx),
and rejects any other forms.
For a more flexible UUID string parser,
please use third party UUID libraries.
This function is suitable for reading with TJSONProtocol.
Type Parameters:
T: any Pointer is the generic (type parameter) version of the helper function that
converts types to pointer types.
Prepends additional information to an error without losing the Thrift exception interface
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.
SetHeader sets a header in the context.
SetReadHeaderList sets the key list of read THeaders in the context.
SetResponseHelper injects TResponseHelper into the context object.
SetWriteHeaderList sets the key list of THeaders to write in the context.
Skips over the next data element from the provided input TProtocol object.
Skips over the next data element from the provided input TProtocol object.
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.
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.
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.
THeaderProtocolIDPtrMust validates and returns the pointer to id.
It's similar to THeaderProtocolIDPtr, but it panics on validation errors
instead of returning them.
TProtocolFactoryConf wraps a TProtocolFactory to propagate
TConfiguration on the factory's GetProtocol calls.
TTransportFactoryConf wraps a TTransportFactory to propagate
TConfiguration on the factory's GetTransport calls.
UnsetHeader unsets a previously set header in the context.
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]
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]
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.
Package-Level Variables (total 26)
Default to using the shared http client. Library users are
free to change this global client or specify one through
THttpClientOptions.
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.
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.
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.
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.