Documentation ¶
Overview ¶
Package kbin contains Kafka primitive reading and writing functions.
Index ¶
- Variables
- func AppendArrayLen(dst []byte, l int) []byte
- func AppendBool(dst []byte, v bool) []byte
- func AppendBytes(dst, b []byte) []byte
- func AppendCompactArrayLen(dst []byte, l int) []byte
- func AppendCompactBytes(dst, b []byte) []byte
- func AppendCompactNullableArrayLen(dst []byte, l int, isNil bool) []byte
- func AppendCompactNullableBytes(dst, b []byte) []byte
- func AppendCompactNullableString(dst []byte, s *string) []byte
- func AppendCompactString(dst []byte, s string) []byte
- func AppendFloat64(dst []byte, f float64) []byte
- func AppendInt16(dst []byte, i int16) []byte
- func AppendInt32(dst []byte, i int32) []byte
- func AppendInt64(dst []byte, i int64) []byte
- func AppendInt8(dst []byte, i int8) []byte
- func AppendNullableArrayLen(dst []byte, l int, isNil bool) []byte
- func AppendNullableBytes(dst, b []byte) []byte
- func AppendNullableString(dst []byte, s *string) []byte
- func AppendString(dst []byte, s string) []byte
- func AppendUint16(dst []byte, u uint16) []byte
- func AppendUint32(dst []byte, u uint32) []byte
- func AppendUuid(dst []byte, uuid [16]byte) []byte
- func AppendUvarint(dst []byte, u uint32) []byte
- func AppendVarint(dst []byte, i int32) []byte
- func AppendVarintBytes(dst, b []byte) []byte
- func AppendVarintString(dst []byte, s string) []byte
- func AppendVarlong(dst []byte, i int64) []byte
- func UnsafeString(slice []byte) string
- func Uvarint(in []byte) (uint32, int)
- func UvarintLen(u uint32) int
- func Varint(in []byte) (int32, int)
- func VarintLen(i int32) int
- func Varlong(in []byte) (int64, int)
- func VarlongLen(i int64) int
- type Reader
- func (b *Reader) ArrayLen() int32
- func (b *Reader) Bool() bool
- func (b *Reader) Bytes() []byte
- func (b *Reader) CompactArrayLen() int32
- func (b *Reader) CompactBytes() []byte
- func (b *Reader) CompactNullableBytes() []byte
- func (b *Reader) CompactNullableString() *string
- func (b *Reader) CompactString() string
- func (b *Reader) Complete() error
- func (b *Reader) Float64() float64
- func (b *Reader) Int16() int16
- func (b *Reader) Int32() int32
- func (b *Reader) Int64() int64
- func (b *Reader) Int8() int8
- func (b *Reader) NullableBytes() []byte
- func (b *Reader) NullableString() *string
- func (b *Reader) Ok() bool
- func (b *Reader) Span(l int) []byte
- func (b *Reader) String() string
- func (b *Reader) Uint16() uint16
- func (b *Reader) Uint32() uint32
- func (b *Reader) UnsafeCompactNullableString() *string
- func (b *Reader) UnsafeCompactString() string
- func (b *Reader) UnsafeNullableString() *string
- func (b *Reader) UnsafeString() string
- func (b *Reader) UnsafeVarintString() string
- func (b *Reader) Uuid() [16]byte
- func (b *Reader) Uvarint() uint32
- func (b *Reader) Varint() int32
- func (b *Reader) VarintArrayLen() int32
- func (b *Reader) VarintBytes() []byte
- func (b *Reader) VarintString() string
- func (b *Reader) Varlong() int64
Constants ¶
This section is empty.
Variables ¶
var ErrNotEnoughData = errors.New("response did not contain enough data to be valid")
ErrNotEnoughData is returned when a type could not fully decode from a slice because the slice did not have enough data.
Functions ¶
func AppendArrayLen ¶
AppendArrayLen appends the length of an array as an int32 to dst.
func AppendBool ¶
AppendBool appends 1 for true or 0 for false to dst.
func AppendBytes ¶
AppendBytes appends bytes to dst prefixed with its int32 length.
func AppendCompactArrayLen ¶
AppendCompactArrayLen appends the length of an array as a uvarint to dst as the length + 1.
For KIP-482.
func AppendCompactBytes ¶
AppendCompactBytes appends bytes to dst prefixed with a its uvarint length starting at 1; 0 is reserved for null, which compact bytes are not (nullable compact ones are!). Thus, the length is the decoded uvarint - 1.
For KIP-482.
func AppendCompactNullableArrayLen ¶
AppendCompactNullableArrayLen appends the length of an array as a uvarint to dst as the length + 1; if isNil is true, this appends 0 as a uvarint.
For KIP-482.
func AppendCompactNullableBytes ¶
AppendCompactNullableBytes appends a potentially nil slice to dst with its uvarint length starting at 1, with 0 indicating null. Thus, the length is the decoded uvarint - 1.
For KIP-482.
func AppendCompactNullableString ¶
AppendCompactNullableString appends a potentially nil string to dst with its uvarint length starting at 1, with 0 indicating null. Thus, the length is the decoded uvarint - 1.
For KIP-482.
func AppendCompactString ¶
AppendCompactString appends a string to dst prefixed with its uvarint length starting at 1; 0 is reserved for null, which compact strings are not (nullable compact ones are!). Thus, the length is the decoded uvarint - 1.
For KIP-482.
func AppendFloat64 ¶
AppendFloat64 appends a big endian float64 to dst.
func AppendInt16 ¶
AppendInt16 appends a big endian int16 to dst.
func AppendInt32 ¶
AppendInt32 appends a big endian int32 to dst.
func AppendInt64 ¶
AppendInt64 appends a big endian int64 to dst.
func AppendNullableArrayLen ¶
AppendNullableArrayLen appends the length of an array as an int32 to dst, or -1 if isNil is true.
func AppendNullableBytes ¶
AppendNullableBytes appends a potentially nil slice to dst prefixed with its int32 length or int32(-1) if nil.
func AppendNullableString ¶
AppendNullableString appends potentially nil string to dst prefixed with its int16 length or int16(-1) if nil.
func AppendString ¶
AppendString appends a string to dst prefixed with its int16 length.
func AppendUint16 ¶ added in v0.6.4
AppendUint16 appends a big endian uint16 to dst.
func AppendUint32 ¶
AppendUint32 appends a big endian uint32 to dst.
func AppendUuid ¶ added in v0.6.2
AppendUuid appends the 16 uuid bytes to dst.
func AppendUvarint ¶
AppendUvarint appends a uvarint encoded u to dst.
func AppendVarint ¶
AppendVarint appends a varint encoded i to dst.
func AppendVarintBytes ¶
AppendVarintBytes appends a slice to dst prefixed with its length encoded as a varint.
func AppendVarintString ¶
AppendVarintString appends a string to dst prefixed with its length encoded as a varint.
func AppendVarlong ¶ added in v1.11.4
AppendVarlong appends a varint encoded i to dst.
func UnsafeString ¶ added in v1.6.0
UnsafeString returns the slice as a string using unsafe rule (6).
func Uvarint ¶
Uvarint is a loop unrolled 32 bit uvarint decoder. The return semantics are the same as binary.Uvarint, with the added benefit that overflows in 5 byte encodings are handled rather than left to the user.
func UvarintLen ¶
UvarintLen returns how long u would be if it were uvarint encoded.
func Varint ¶
Varint is a loop unrolled 32 bit varint decoder. The return semantics are the same as binary.Varint, with the added benefit that overflows in 5 byte encodings are handled rather than left to the user.
func Varlong ¶ added in v1.11.4
Varlong is a loop unrolled 64 bit varint decoder. The return semantics are the same as binary.Varint, with the added benefit that overflows in 10 byte encodings are handled rather than left to the user.
func VarlongLen ¶ added in v1.11.5
VarlongLen returns how long i would be if it were varlong encoded.
Types ¶
type Reader ¶
type Reader struct { Src []byte // contains filtered or unexported fields }
Reader is used to decode Kafka messages.
For all functions on Reader, if the reader has been invalidated, functions return defaults (false, 0, nil, ""). Use Complete to detect if the reader was invalidated or if the reader has remaining data.
func (*Reader) CompactArrayLen ¶
CompactArrayLen returns a Kafka compact array length from the reader.
func (*Reader) CompactBytes ¶
CompactBytes returns a Kafka compact byte array from the reader.
This never returns nil.
func (*Reader) CompactNullableBytes ¶
CompactNullableBytes returns a Kafka compact nullable byte array from the reader, returning nil as appropriate.
func (*Reader) CompactNullableString ¶
CompactNullableString returns a Kafka compact nullable string from the reader.
func (*Reader) CompactString ¶
CompactString returns a Kafka compact string from the reader.
func (*Reader) NullableBytes ¶
NullableBytes returns a Kafka nullable byte array from the reader, returning nil as appropriate.
func (*Reader) NullableString ¶
NullableString returns a Kafka nullable string from the reader.
func (*Reader) UnsafeCompactNullableString ¶ added in v1.6.0
UnsafeCompactNullableString returns a Kafka compact nullable string from the reader without allocating using the unsafe package. This must be used with care; note the string holds a reference to the original slice.
func (*Reader) UnsafeCompactString ¶ added in v1.6.0
UnsafeCompactString returns a Kafka compact string from the reader without allocating using the unsafe package. This must be used with care; note the string holds a reference to the original slice.
func (*Reader) UnsafeNullableString ¶ added in v1.6.0
UnsafeNullableString returns a Kafka nullable string from the reader without allocating using the unsafe package. This must be used with care; note the string holds a reference to the original slice.
func (*Reader) UnsafeString ¶ added in v1.6.0
UnsafeString returns a Kafka string from the reader without allocating using the unsafe package. This must be used with care; note the string holds a reference to the original slice.
func (*Reader) UnsafeVarintString ¶ added in v1.6.0
UnsafeVarintString returns a Kafka encoded varint string from the reader without allocating using the unsafe package. This must be used with care; note the string holds a reference to the original slice.
func (*Reader) VarintArrayLen ¶
VarintArrayLen returns a Kafka array length from the reader.
func (*Reader) VarintBytes ¶
VarintBytes returns a Kafka encoded varint array from the reader, returning nil as appropriate.
func (*Reader) VarintString ¶
VarintString returns a Kafka encoded varint string from the reader.