Documentation
¶
Overview ¶
Package stream provides streaming implementations of encoding and decoding Thrift values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BodyReader ¶
BodyReader represents a type that can be read out from a stream.Reader.
type EnvelopeHeader ¶
type EnvelopeHeader struct {
Name string
Type wire.EnvelopeType
SeqID int32
}
EnvelopeHeader represents the envelope of a response or a request which includes metadata about the method, the type of data in the envelope, and the value. It is equivalent of `wire.Envelope`, but for streaming purposes.
type Enveloper ¶
type Enveloper interface {
MethodName() string
EnvelopeType() wire.EnvelopeType
Encode(Writer) error
}
Enveloper is the interface implemented by a type that can be written with an envelope via a stream.Writer.
type FieldHeader ¶
FieldHeader defines the metadata needed to define the beginning of a field in a Thrift value.
type ListHeader ¶
ListHeader defines the metadata needed to define the beginning of a list in a Thrift value.
type MapHeader ¶
MapHeader defines the metadata needed to define the beginning of a map in a Thrift value.
type Protocol ¶
type Protocol interface {
// Writer returns a streaming implementation of an encoder for a
// Thrift value.
Writer(w io.Writer) Writer
// Reader returns a streaming implementation of a decoder for a
// Thrift value.
Reader(r io.Reader) Reader
}
Protocol defines a specific way for a Thrift value to be encoded or decoded, implemented in a streaming fashion.
type Reader ¶
type Reader interface {
ReadBool() (bool, error)
ReadInt8() (int8, error)
ReadInt16() (int16, error)
ReadInt32() (int32, error)
ReadInt64() (int64, error)
ReadString() (string, error)
ReadDouble() (float64, error)
ReadBinary() ([]byte, error)
ReadStructBegin() error
ReadStructEnd() error
ReadFieldBegin() (FieldHeader, bool, error)
ReadFieldEnd() error
ReadListBegin() (ListHeader, error)
ReadListEnd() error
ReadSetBegin() (SetHeader, error)
ReadSetEnd() error
ReadMapBegin() (MapHeader, error)
ReadMapEnd() error
Close() error
ReadEnvelopeBegin() (EnvelopeHeader, error)
ReadEnvelopeEnd() error
// Skip skips over the bytes of the wire type and any applicable headers.
Skip(w wire.Type) error
}
Reader defines an decoder for a Thrift value, implemented in a streaming fashion.
type RequestReader ¶
type RequestReader interface {
// ReadRequest reads off the request envelope (if present) from an io.Reader,
// using the provided BodyReader to read off the full request struct,
// asserting the EnvelopeType (either OneWay or Unary) if an envlope exists.
// A ResponseWriter that understands the enveloping used and the request's
// body are returned.
//
// This allows a Thrift request handler to transparently read requests
// regardless of whether the caller is configured to submit envelopes.
ReadRequest(context.Context, wire.EnvelopeType, io.Reader, BodyReader) (ResponseWriter, error)
}
RequestReader captures how to read from a request in a streaming fashion.
type ResponseWriter ¶
type ResponseWriter interface {
// WriteResponse writes a response to the Writer with the envelope
// style of the corresponding request, and returns a stream.Writer to write
// remaining un-enveloped response bytes. Once writing of the response is complete,
// whether successful or not (error), users must call Close() on the stream.Writer.
//
// The EnvelopeType should be either wire.Reply or wire.Exception.
WriteResponse(wire.EnvelopeType, io.Writer, Enveloper) error
}
ResponseWriter captures how to respond to a request in a streaming fashion.
type SetHeader ¶
SetHeader defines the metadata needed to define the beginning of a set in a Thrift value.
type Writer ¶
type Writer interface {
WriteBool(b bool) error
WriteInt8(i int8) error
WriteInt16(i int16) error
WriteInt32(i int32) error
WriteInt64(i int64) error
WriteString(s string) error
WriteDouble(f float64) error
WriteBinary(b []byte) error
WriteStructBegin() error
WriteStructEnd() error
WriteFieldBegin(f FieldHeader) error
WriteFieldEnd() error
WriteMapBegin(m MapHeader) error
WriteMapEnd() error
WriteSetBegin(s SetHeader) error
WriteSetEnd() error
WriteListBegin(l ListHeader) error
WriteListEnd() error
WriteEnvelopeBegin(eh EnvelopeHeader) error
WriteEnvelopeEnd() error
Close() error
}
Writer defines an encoder for a Thrift value, implemented in a streaming fashion.