fields

package
v0.0.0-...-d5e11c2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayMarshalJSON

func ArrayMarshalJSON[T bool | float64 | int8 | int16 | uint16 | int32 | int64 | NullableString](key string, data []T) ([]byte, error)

func ArrayOfStructMarshalJSON

func ArrayOfStructMarshalJSON[T any](key string, data []T) ([]byte, error)

func BytesMarshalJSON

func BytesMarshalJSON(key string, data []byte) ([]byte, error)

func IsControlBatch

func IsControlBatch(attributes int16) bool

IsControlBatch returns true if the passed in attributes has the 'isControlBatch' flag set according to https://kafka.apache.org/documentation/#recordbatch

func IsTransactional

func IsTransactional(attributes int16) bool

IsTransactional returns true if the passed in attributes has the 'isTransactional' flag set according to https://kafka.apache.org/documentation/#recordbatch

func MarshalPrimitiveTypeJSON

func MarshalPrimitiveTypeJSON[T bool | float64 | int8 | int16 | uint16 | int32 | int64 | NullableString](val T) ([]byte, error)

func NullableStringSliceEqual

func NullableStringSliceEqual(x, y []NullableString) bool

func PrimitiveTypeSliceEqual

func PrimitiveTypeSliceEqual[T bool | int8 | int16 | uint16 | int32 | int64 | float64, S []T](x, y S) bool

func RawTaggedFieldsEqual

func RawTaggedFieldsEqual(x, y []RawTaggedField) bool

func WriteRawTaggedFields

func WriteRawTaggedFields(buf *typesbytes.SliceWriter, taggedFields []RawTaggedField) error

Types

type Array

type Array[T bool | float64 | int8 | int16 | uint16 | int32 | int64 | NullableString, P PrimitiveTypeProcessor[T]] struct {
	ElementProcessor P
	Context
}

func (*Array[T, P]) Read

func (f *Array[T, P]) Read(r *bytes.Reader, version int16) ([]T, error)

func (*Array[T, P]) SizeInBytes

func (f *Array[T, P]) SizeInBytes(version int16, data []T) (int, error)

SizeInBytes returns the size of data in bytes when it's serialized

func (*Array[T, P]) Write

func (f *Array[T, P]) Write(w *typesbytes.SliceWriter, version int16, data []T) error

type ArrayOfStruct

type ArrayOfStruct[T any, P StructType] struct {
	Context
}

func (*ArrayOfStruct[T, P]) Read

func (f *ArrayOfStruct[T, P]) Read(buf *bytes.Reader, version int16) ([]T, error)

func (*ArrayOfStruct[T, P]) SizeInBytes

func (f *ArrayOfStruct[T, P]) SizeInBytes(version int16, data []T) (int, error)

SizeInBytes returns the size of data in bytes when it's serialized

func (*ArrayOfStruct[T, P]) Write

func (f *ArrayOfStruct[T, P]) Write(w *typesbytes.SliceWriter, version int16, data []T) error

type BatchRecord

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

BatchRecord provides setter/getter methods for kafka records https://kafka.apache.org/documentation/#record

func (*BatchRecord) Equal

func (r *BatchRecord) Equal(that *BatchRecord) bool

func (*BatchRecord) Headers

func (r *BatchRecord) Headers() []RecordHeader

func (*BatchRecord) Key

func (r *BatchRecord) Key() []byte

func (*BatchRecord) MarshalJSON

func (r *BatchRecord) MarshalJSON() ([]byte, error)

func (*BatchRecord) OffsetDelta

func (r *BatchRecord) OffsetDelta() int32

func (*BatchRecord) Read

func (r *BatchRecord) Read(rd *serialization.Reader) error

func (*BatchRecord) Release

func (r *BatchRecord) Release()

func (*BatchRecord) SetHeaders

func (r *BatchRecord) SetHeaders(headers []RecordHeader)

func (*BatchRecord) SetKey

func (r *BatchRecord) SetKey(key []byte)

func (*BatchRecord) SetOffsetDelta

func (r *BatchRecord) SetOffsetDelta(offsetDelta int32)

func (*BatchRecord) SetTimestampDelta

func (r *BatchRecord) SetTimestampDelta(timestampDelta int64)

func (*BatchRecord) SetValue

func (r *BatchRecord) SetValue(value []byte)

func (*BatchRecord) SizeInBytes

func (r *BatchRecord) SizeInBytes() int

func (*BatchRecord) String

func (r *BatchRecord) String() string

func (*BatchRecord) TimestampDelta

func (r *BatchRecord) TimestampDelta() int64

func (*BatchRecord) Value

func (r *BatchRecord) Value() []byte

func (*BatchRecord) Write

func (r *BatchRecord) Write(w *serialization.Writer) error

type Bool

type Bool struct {
	Context
}

func (*Bool) Read

func (f *Bool) Read(r *bytes.Reader, version int16, out *bool) error

func (*Bool) SizeInBytes

func (f *Bool) SizeInBytes(version int16, _ bool) (int, error)

SizeInBytes returns the size of this field in bytes when it's serialized

func (*Bool) Write

func (f *Bool) Write(w *typesbytes.SliceWriter, version int16, data bool) error

type Bytes

type Bytes struct {
	Context
}

func (*Bytes) Read

func (f *Bytes) Read(r *bytes.Reader, version int16, out *[]byte) error

func (*Bytes) SizeInBytes

func (f *Bytes) SizeInBytes(version int16, data []byte) (int, error)

SizeInBytes returns the size of data in bytes when it's serialized

func (*Bytes) Write

func (f *Bytes) Write(w *typesbytes.SliceWriter, version int16, data []byte) error

type CompressionType

type CompressionType int8

CompressionType represents the compression applied to a record batch.

const (
	None   CompressionType = 0
	Gzip   CompressionType = 1
	Snappy CompressionType = 2
	Lz4    CompressionType = 3
	Zstd   CompressionType = 4
)

func GetCompressionType

func GetCompressionType(attributes int16) CompressionType

GetCompressionType returns true if the passed in attributes has either 'gzip', 'snappy', 'lz4' or 'zstd' flag set according to https://kafka.apache.org/documentation/#recordbatch

type Context

type Context struct {
	CustomDefaultValue              any
	SpecName                        string
	SpecTag                         OptionalTag
	LowestSupportedVersion          int16
	HighestSupportedVersion         int16
	LowestSupportedFlexVersion      int16
	HighestSupportedFlexVersion     int16
	LowestSupportedNullableVersion  int16
	HighestSupportedNullableVersion int16
	LowestSupportedTaggedVersion    int16
	HighestSupportedTaggedVersion   int16
}

func (*Context) IsFlexibleVersion

func (f *Context) IsFlexibleVersion(version int16) bool

func (*Context) IsNullableVersion

func (f *Context) IsNullableVersion(version int16) bool

func (*Context) IsSupportedVersion

func (f *Context) IsSupportedVersion(version int16) bool

func (*Context) IsTaggedVersion

func (f *Context) IsTaggedVersion(version int16) bool

func (*Context) Name

func (f *Context) Name() string

func (*Context) NonTaggedVersionsSupported

func (f *Context) NonTaggedVersionsSupported() bool

func (*Context) OnlyTaggedVersionsSupported

func (f *Context) OnlyTaggedVersionsSupported() bool

func (*Context) Tag

func (f *Context) Tag() OptionalTag

type Float64

type Float64 struct {
	Context
}

func (*Float64) Read

func (f *Float64) Read(r *bytes.Reader, version int16, out *float64) error

func (*Float64) SizeInBytes

func (f *Float64) SizeInBytes(version int16, _ float64) (int, error)

SizeInBytes returns the size of this field in bytes when it's serialized

func (*Float64) Write

func (f *Float64) Write(w *typesbytes.SliceWriter, version int16, data float64) error

type Int16

type Int16 struct {
	Context
}

func (*Int16) Read

func (f *Int16) Read(buf *bytes.Reader, version int16, out *int16) error

func (*Int16) SizeInBytes

func (f *Int16) SizeInBytes(version int16, _ int16) (int, error)

SizeInBytes returns the size of this field in bytes when it's serialized

func (*Int16) Write

func (f *Int16) Write(w *typesbytes.SliceWriter, version int16, data int16) error

type Int32

type Int32 struct {
	Context
}

func (*Int32) Read

func (f *Int32) Read(buf *bytes.Reader, version int16, out *int32) error

func (*Int32) SizeInBytes

func (f *Int32) SizeInBytes(version int16, _ int32) (int, error)

SizeInBytes returns the size of this field in bytes when it's serialized

func (*Int32) Write

func (f *Int32) Write(w *typesbytes.SliceWriter, version int16, data int32) error

type Int64

type Int64 struct {
	Context
}

func (*Int64) Read

func (f *Int64) Read(buf *bytes.Reader, version int16, out *int64) error

func (*Int64) SizeInBytes

func (f *Int64) SizeInBytes(version int16, _ int64) (int, error)

SizeInBytes returns the size of this field in bytes when it's serialized

func (*Int64) Write

func (f *Int64) Write(w *typesbytes.SliceWriter, version int16, data int64) error

type Int8

type Int8 struct {
	Context
}

func (*Int8) Read

func (f *Int8) Read(buf *bytes.Reader, version int16, out *int8) error

func (*Int8) SizeInBytes

func (f *Int8) SizeInBytes(version int16, _ int8) (int, error)

SizeInBytes returns the size of this field in bytes when it's serialized

func (*Int8) Write

func (f *Int8) Write(w *typesbytes.SliceWriter, version int16, data int8) error

type NullableString

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

func (*NullableString) Bytes

func (s *NullableString) Bytes() []byte

func (*NullableString) Clear

func (s *NullableString) Clear()

func (*NullableString) Equal

func (s *NullableString) Equal(that *NullableString) bool

func (*NullableString) IsNil

func (s *NullableString) IsNil() bool

func (*NullableString) MarshalJSON

func (s *NullableString) MarshalJSON() ([]byte, error)

func (*NullableString) Release

func (s *NullableString) Release()

func (*NullableString) SetValue

func (s *NullableString) SetValue(value string)

func (*NullableString) String

func (s *NullableString) String() string

func (*NullableString) Value

func (s *NullableString) Value() string

type OptionalTag

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

func Tag

func Tag(tag uint32) OptionalTag

func (*OptionalTag) Get

func (t *OptionalTag) Get() uint32

func (*OptionalTag) IsDefined

func (t *OptionalTag) IsDefined() bool

func (*OptionalTag) Set

func (t *OptionalTag) Set(tag uint32)

type PrimitiveTypeProcessor

type PrimitiveTypeProcessor[T bool | float64 | int8 | int16 | uint16 | int32 | int64 | NullableString] interface {
	Read(buf *bytes.Reader, messageVersion int16, out *T) error
	Write(w *typesbytes.SliceWriter, messageVersion int16, data T) error
	SizeInBytes(version int16, data T) (int, error)
}

type RawTaggedField

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

RawTaggedField provides setter/getter methods for raw tagged fields

func ReadRawTaggedFields

func ReadRawTaggedFields(buf *bytes.Reader) ([]RawTaggedField, error)

func (*RawTaggedField) Equal

func (r *RawTaggedField) Equal(that *RawTaggedField) bool

func (*RawTaggedField) MarshalJSON

func (r *RawTaggedField) MarshalJSON() ([]byte, error)

func (*RawTaggedField) Release

func (r *RawTaggedField) Release()

func (*RawTaggedField) SetTag

func (r *RawTaggedField) SetTag(tag uint32)

func (*RawTaggedField) SetValue

func (r *RawTaggedField) SetValue(value []byte)

func (*RawTaggedField) String

func (r *RawTaggedField) String() string

func (*RawTaggedField) Tag

func (r *RawTaggedField) Tag() uint32

func (*RawTaggedField) Value

func (r *RawTaggedField) Value() []byte

type RecordBatch

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

RecordBatch provides setter/getter methods for kafka record batch https://kafka.apache.org/documentation/#recordbatch

func (*RecordBatch) Attributes

func (b *RecordBatch) Attributes() int16

func (*RecordBatch) BaseOffset

func (b *RecordBatch) BaseOffset() int64

func (*RecordBatch) BaseSequence

func (b *RecordBatch) BaseSequence() int32

func (*RecordBatch) BaseTimestamp

func (b *RecordBatch) BaseTimestamp() int64

func (*RecordBatch) Clear

func (b *RecordBatch) Clear()

func (*RecordBatch) Complete

func (b *RecordBatch) Complete()

func (*RecordBatch) CompressionType

func (b *RecordBatch) CompressionType() CompressionType

CompressionType returns true if the passed in attributes has either 'gzip', 'snappy', 'lz4' or 'zstd' flag set according to https://kafka.apache.org/documentation/#recordbatch

func (*RecordBatch) Equal

func (b *RecordBatch) Equal(that *RecordBatch) bool

func (*RecordBatch) IsComplete

func (b *RecordBatch) IsComplete() bool

func (*RecordBatch) IsControlBatch

func (b *RecordBatch) IsControlBatch() bool

func (*RecordBatch) IsTransactional

func (b *RecordBatch) IsTransactional() bool

func (*RecordBatch) LastOffsetDelta

func (b *RecordBatch) LastOffsetDelta() int32

func (*RecordBatch) Magic

func (b *RecordBatch) Magic() int8

func (*RecordBatch) MarshalJSON

func (b *RecordBatch) MarshalJSON() ([]byte, error)

func (*RecordBatch) MaxTimestamp

func (b *RecordBatch) MaxTimestamp() int64

func (*RecordBatch) PartitionLeaderEpoch

func (b *RecordBatch) PartitionLeaderEpoch() int32

func (*RecordBatch) ProducerEpoch

func (b *RecordBatch) ProducerEpoch() int16

func (*RecordBatch) ProducerId

func (b *RecordBatch) ProducerId() int64

func (*RecordBatch) Read

func (*RecordBatch) Records

func (b *RecordBatch) Records() []BatchRecord

func (*RecordBatch) Release

func (b *RecordBatch) Release()

func (*RecordBatch) SetAttributes

func (b *RecordBatch) SetAttributes(attributes int16)

func (*RecordBatch) SetBaseOffset

func (b *RecordBatch) SetBaseOffset(baseOffset int64)

func (*RecordBatch) SetBaseSequence

func (b *RecordBatch) SetBaseSequence(baseSequence int32)

func (*RecordBatch) SetBaseTimestamp

func (b *RecordBatch) SetBaseTimestamp(baseTimestamp int64)

func (*RecordBatch) SetLastOffsetDelta

func (b *RecordBatch) SetLastOffsetDelta(lastOffsetDelta int32)

func (*RecordBatch) SetMaxTimestamp

func (b *RecordBatch) SetMaxTimestamp(maxTimestamp int64)

func (*RecordBatch) SetPartitionLeaderEpoch

func (b *RecordBatch) SetPartitionLeaderEpoch(partitionLeaderEpoch int32)

func (*RecordBatch) SetProducerEpoch

func (b *RecordBatch) SetProducerEpoch(producerEpoch int16)

func (*RecordBatch) SetProducerId

func (b *RecordBatch) SetProducerId(producerId int64)

func (*RecordBatch) SetRecords

func (b *RecordBatch) SetRecords(records []BatchRecord)

func (*RecordBatch) SizeInBytes

func (b *RecordBatch) SizeInBytes() int

SizeInBytes returns the size of this record batch when it's records are not compressed

func (*RecordBatch) String

func (b *RecordBatch) String() string

func (*RecordBatch) Write

func (b *RecordBatch) Write(buf *typesbytes.SliceWriter) error

type RecordBatches

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

RecordBatches manipulates RecordBatch collections

func (*RecordBatches) Clear

func (b *RecordBatches) Clear()

func (*RecordBatches) ClearAndComplete

func (b *RecordBatches) ClearAndComplete()

func (*RecordBatches) Complete

func (b *RecordBatches) Complete()

func (*RecordBatches) Equal

func (b *RecordBatches) Equal(that *RecordBatches) bool

func (*RecordBatches) IsNil

func (b *RecordBatches) IsNil() bool

func (*RecordBatches) Items

func (b *RecordBatches) Items() []RecordBatch

func (*RecordBatches) MarshalJSON

func (b *RecordBatches) MarshalJSON() ([]byte, error)

func (*RecordBatches) Read

func (*RecordBatches) Release

func (b *RecordBatches) Release()

func (*RecordBatches) SetItems

func (b *RecordBatches) SetItems(items []RecordBatch)

func (*RecordBatches) SizeInBytes

func (b *RecordBatches) SizeInBytes() int

SizeInBytes returns the size of this record batch in bytes when it's serialized

func (*RecordBatches) String

func (b *RecordBatches) String() string

func (*RecordBatches) Write

func (b *RecordBatches) Write(buf *typesbytes.SliceWriter) error

type RecordHeader

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

RecordHeader provides setter/getter methods for kafka record headers https://kafka.apache.org/documentation/#recordheader

func (*RecordHeader) Equal

func (h *RecordHeader) Equal(that *RecordHeader) bool

func (*RecordHeader) Key

func (h *RecordHeader) Key() string

func (*RecordHeader) MarshalJSON

func (h *RecordHeader) MarshalJSON() ([]byte, error)

func (*RecordHeader) Read

func (h *RecordHeader) Read(r *serialization.Reader) error

func (*RecordHeader) Release

func (h *RecordHeader) Release()

func (*RecordHeader) SetKey

func (h *RecordHeader) SetKey(key string)

func (*RecordHeader) SetValue

func (h *RecordHeader) SetValue(value []byte)

func (*RecordHeader) SizeInBytes

func (h *RecordHeader) SizeInBytes() int

func (*RecordHeader) String

func (h *RecordHeader) String() string

func (*RecordHeader) Value

func (h *RecordHeader) Value() []byte

func (*RecordHeader) Write

func (h *RecordHeader) Write(w *serialization.Writer) error

type Records

type Records struct {
	Context
}

func (*Records) Read

func (f *Records) Read(buf *bytes.Reader, version int16, out *RecordBatches) error

func (*Records) SizeInBytes

func (f *Records) SizeInBytes(version int16, data *RecordBatches) (int, error)

func (*Records) Write

func (f *Records) Write(buf *typesbytes.SliceWriter, version int16, data *RecordBatches) error

type String

type String struct {
	Context
}

func (*String) Read

func (s *String) Read(buf *bytes.Reader, version int16, out *NullableString) error

func (*String) SizeInBytes

func (s *String) SizeInBytes(version int16, data NullableString) (int, error)

SizeInBytes returns the size of data in bytes when it's serialized

func (*String) Write

func (s *String) Write(w *typesbytes.SliceWriter, version int16, data NullableString) error

type StructType

type StructType interface {
	Read(r *bytes.Reader, messageVersion int16) error
	Write(w *typesbytes.SliceWriter, messageVersion int16) error
	SizeInBytes(version int16) (int, error)
	MarshalJSON() ([]byte, error)
}

type UUID

type UUID [16]byte

func (*UUID) IsZero

func (u *UUID) IsZero() bool

func (*UUID) SetZero

func (u *UUID) SetZero()

type Uint16

type Uint16 struct {
	Context
}

func (*Uint16) Read

func (f *Uint16) Read(buf *bytes.Reader, version int16, out *uint16) error

func (*Uint16) SizeInBytes

func (f *Uint16) SizeInBytes(version int16, _ uint16) (int, error)

SizeInBytes returns the size of this field in bytes when it's serialized

func (*Uint16) Write

func (f *Uint16) Write(w *typesbytes.SliceWriter, version int16, data uint16) error

type Uuid

type Uuid struct {
	Context
}

func (*Uuid) Read

func (f *Uuid) Read(buf *bytes.Reader, version int16, out *UUID) error

func (*Uuid) SizeInBytes

func (f *Uuid) SizeInBytes(version int16, _ UUID) (int, error)

SizeInBytes returns the size of this field in bytes when it's serialized

func (*Uuid) Write

func (f *Uuid) Write(w *typesbytes.SliceWriter, version int16, data UUID) error

Jump to

Keyboard shortcuts

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