serialize

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: Apache-2.0 Imports: 13 Imported by: 32

Documentation

Overview

Package serialize is a generated GoMock package.

Index

Constants

View Source
const (

	// DefaultMaxTagLiteralLength is the maximum length of a tag Name/Value.
	DefaultMaxTagLiteralLength uint16 = math.MaxUint16
)
View Source
const (
	// HeaderMagicNumber is an internal header used to denote the beginning of
	// an encoded stream.
	HeaderMagicNumber uint16 = 10101
)

Variables

View Source
var (
	// ByteOrder is the byte order used for encoding tags into a byte sequence.
	ByteOrder binary.ByteOrder = binary.LittleEndian
)
View Source
var (

	// ErrEmptyTagNameLiteral is an error when encoded tag name is empty.
	ErrEmptyTagNameLiteral = xerrors.NewInvalidParamsError(errors.New("tag name cannot be empty"))
)
View Source
var (
	// ErrIncorrectHeader is an error when encoded tag byte sequence doesn't start with
	// an expected magic number.
	ErrIncorrectHeader = errors.New("header magic number does not match expected value")
)

Functions

func TagValueFromEncodedTagsFast added in v1.0.0

func TagValueFromEncodedTagsFast(
	encodedTags []byte,
	tagName []byte,
) ([]byte, bool, error)

TagValueFromEncodedTagsFast returns a tag from a set of encoded tags without any pooling required.

Types

type FakeTagEncoder added in v1.2.0

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

FakeTagEncoder is a fake TagEncoder for testing. It encodes a set of TagPair as name1#value1#name2#value#...

func (*FakeTagEncoder) Data added in v1.2.0

func (f *FakeTagEncoder) Data() (checked.Bytes, bool)

Data gets the encoded tags.

func (*FakeTagEncoder) Decode added in v1.2.0

func (f *FakeTagEncoder) Decode() []id.TagPair

Decode the encoded data back into a set of TagPairs.

func (*FakeTagEncoder) Encode added in v1.2.0

func (f *FakeTagEncoder) Encode(tags ident.TagIterator) error

Encode the tags. The original tags can be retrieved with Decode for testing.

func (*FakeTagEncoder) Finalize added in v1.2.0

func (f *FakeTagEncoder) Finalize()

Finalize does nothing.

func (*FakeTagEncoder) Reset added in v1.2.0

func (f *FakeTagEncoder) Reset()

Reset the stored encoded data.

type MetricTagsIterator

type MetricTagsIterator interface {
	id.ID
	id.SortedTagIterator
	NumTags() int
}

MetricTagsIterator iterates over a set of tags.

func NewMetricTagsIterator

func NewMetricTagsIterator(
	tagDecoder TagDecoder,
	pool MetricTagsIteratorPool,
) MetricTagsIterator

NewMetricTagsIterator creates a MetricTagsIterator.

func NewUncheckedMetricTagsIterator added in v1.4.2

func NewUncheckedMetricTagsIterator(tagLimits TagSerializationLimits) MetricTagsIterator

NewUncheckedMetricTagsIterator creates a MetricTagsIterator that removes all safety checks (i.e ref counts). It is suitable to use this when you are confident the provided bytes to iterate are not shared.

type MetricTagsIteratorPool

type MetricTagsIteratorPool interface {
	Init()
	Get() MetricTagsIterator
	Put(iter MetricTagsIterator)
}

MetricTagsIteratorPool pools MetricTagsIterator.

func NewMetricTagsIteratorPool

func NewMetricTagsIteratorPool(
	tagDecoderPool TagDecoderPool,
	opts pool.ObjectPoolOptions,
) MetricTagsIteratorPool

NewMetricTagsIteratorPool creates a MetricTagsIteratorPool.

type MockMetricTagsIterator

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

MockMetricTagsIterator is a mock of MetricTagsIterator interface.

func NewMockMetricTagsIterator

func NewMockMetricTagsIterator(ctrl *gomock.Controller) *MockMetricTagsIterator

NewMockMetricTagsIterator creates a new mock instance.

func (*MockMetricTagsIterator) Bytes

func (m *MockMetricTagsIterator) Bytes() []byte

Bytes mocks base method.

func (*MockMetricTagsIterator) Close

func (m *MockMetricTagsIterator) Close()

Close mocks base method.

func (*MockMetricTagsIterator) Current

func (m *MockMetricTagsIterator) Current() ([]byte, []byte)

Current mocks base method.

func (*MockMetricTagsIterator) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMetricTagsIterator) Err

func (m *MockMetricTagsIterator) Err() error

Err mocks base method.

func (*MockMetricTagsIterator) Next

func (m *MockMetricTagsIterator) Next() bool

Next mocks base method.

func (*MockMetricTagsIterator) NumTags

func (m *MockMetricTagsIterator) NumTags() int

NumTags mocks base method.

func (*MockMetricTagsIterator) Reset

func (m *MockMetricTagsIterator) Reset(arg0 []byte)

Reset mocks base method.

func (*MockMetricTagsIterator) TagValue

func (m *MockMetricTagsIterator) TagValue(arg0 []byte) ([]byte, bool)

TagValue mocks base method.

type MockMetricTagsIteratorMockRecorder

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

MockMetricTagsIteratorMockRecorder is the mock recorder for MockMetricTagsIterator.

func (*MockMetricTagsIteratorMockRecorder) Bytes

Bytes indicates an expected call of Bytes.

func (*MockMetricTagsIteratorMockRecorder) Close

Close indicates an expected call of Close.

func (*MockMetricTagsIteratorMockRecorder) Current

Current indicates an expected call of Current.

func (*MockMetricTagsIteratorMockRecorder) Err

Err indicates an expected call of Err.

func (*MockMetricTagsIteratorMockRecorder) Next

Next indicates an expected call of Next.

func (*MockMetricTagsIteratorMockRecorder) NumTags

NumTags indicates an expected call of NumTags.

func (*MockMetricTagsIteratorMockRecorder) Reset

func (mr *MockMetricTagsIteratorMockRecorder) Reset(arg0 interface{}) *gomock.Call

Reset indicates an expected call of Reset.

func (*MockMetricTagsIteratorMockRecorder) TagValue

func (mr *MockMetricTagsIteratorMockRecorder) TagValue(arg0 interface{}) *gomock.Call

TagValue indicates an expected call of TagValue.

type MockMetricTagsIteratorPool

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

MockMetricTagsIteratorPool is a mock of MetricTagsIteratorPool interface.

func NewMockMetricTagsIteratorPool

func NewMockMetricTagsIteratorPool(ctrl *gomock.Controller) *MockMetricTagsIteratorPool

NewMockMetricTagsIteratorPool creates a new mock instance.

func (*MockMetricTagsIteratorPool) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMetricTagsIteratorPool) Get

Get mocks base method.

func (*MockMetricTagsIteratorPool) Init

func (m *MockMetricTagsIteratorPool) Init()

Init mocks base method.

func (*MockMetricTagsIteratorPool) Put

Put mocks base method.

type MockMetricTagsIteratorPoolMockRecorder

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

MockMetricTagsIteratorPoolMockRecorder is the mock recorder for MockMetricTagsIteratorPool.

func (*MockMetricTagsIteratorPoolMockRecorder) Get

Get indicates an expected call of Get.

func (*MockMetricTagsIteratorPoolMockRecorder) Init

Init indicates an expected call of Init.

func (*MockMetricTagsIteratorPoolMockRecorder) Put

func (mr *MockMetricTagsIteratorPoolMockRecorder) Put(arg0 interface{}) *gomock.Call

Put indicates an expected call of Put.

type MockTagDecoder

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

MockTagDecoder is a mock of TagDecoder interface.

func NewMockTagDecoder

func NewMockTagDecoder(ctrl *gomock.Controller) *MockTagDecoder

NewMockTagDecoder creates a new mock instance.

func (*MockTagDecoder) Close

func (m *MockTagDecoder) Close()

Close mocks base method.

func (*MockTagDecoder) Current

func (m *MockTagDecoder) Current() ident.Tag

Current mocks base method.

func (*MockTagDecoder) CurrentIndex

func (m *MockTagDecoder) CurrentIndex() int

CurrentIndex mocks base method.

func (*MockTagDecoder) Duplicate

func (m *MockTagDecoder) Duplicate() ident.TagIterator

Duplicate mocks base method.

func (*MockTagDecoder) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTagDecoder) Err

func (m *MockTagDecoder) Err() error

Err mocks base method.

func (*MockTagDecoder) Len

func (m *MockTagDecoder) Len() int

Len mocks base method.

func (*MockTagDecoder) Next

func (m *MockTagDecoder) Next() bool

Next mocks base method.

func (*MockTagDecoder) Remaining

func (m *MockTagDecoder) Remaining() int

Remaining mocks base method.

func (*MockTagDecoder) Reset

func (m *MockTagDecoder) Reset(arg0 checked.Bytes)

Reset mocks base method.

func (*MockTagDecoder) Rewind added in v0.15.2

func (m *MockTagDecoder) Rewind()

Rewind mocks base method.

type MockTagDecoderMockRecorder

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

MockTagDecoderMockRecorder is the mock recorder for MockTagDecoder.

func (*MockTagDecoderMockRecorder) Close

func (mr *MockTagDecoderMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockTagDecoderMockRecorder) Current

func (mr *MockTagDecoderMockRecorder) Current() *gomock.Call

Current indicates an expected call of Current.

func (*MockTagDecoderMockRecorder) CurrentIndex

func (mr *MockTagDecoderMockRecorder) CurrentIndex() *gomock.Call

CurrentIndex indicates an expected call of CurrentIndex.

func (*MockTagDecoderMockRecorder) Duplicate

func (mr *MockTagDecoderMockRecorder) Duplicate() *gomock.Call

Duplicate indicates an expected call of Duplicate.

func (*MockTagDecoderMockRecorder) Err

Err indicates an expected call of Err.

func (*MockTagDecoderMockRecorder) Len

Len indicates an expected call of Len.

func (*MockTagDecoderMockRecorder) Next

Next indicates an expected call of Next.

func (*MockTagDecoderMockRecorder) Remaining

func (mr *MockTagDecoderMockRecorder) Remaining() *gomock.Call

Remaining indicates an expected call of Remaining.

func (*MockTagDecoderMockRecorder) Reset

func (mr *MockTagDecoderMockRecorder) Reset(arg0 interface{}) *gomock.Call

Reset indicates an expected call of Reset.

func (*MockTagDecoderMockRecorder) Rewind added in v0.15.2

func (mr *MockTagDecoderMockRecorder) Rewind() *gomock.Call

Rewind indicates an expected call of Rewind.

type MockTagDecoderPool

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

MockTagDecoderPool is a mock of TagDecoderPool interface.

func NewMockTagDecoderPool

func NewMockTagDecoderPool(ctrl *gomock.Controller) *MockTagDecoderPool

NewMockTagDecoderPool creates a new mock instance.

func (*MockTagDecoderPool) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTagDecoderPool) Get

func (m *MockTagDecoderPool) Get() TagDecoder

Get mocks base method.

func (*MockTagDecoderPool) Init

func (m *MockTagDecoderPool) Init()

Init mocks base method.

func (*MockTagDecoderPool) Put

func (m *MockTagDecoderPool) Put(arg0 TagDecoder)

Put mocks base method.

type MockTagDecoderPoolMockRecorder

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

MockTagDecoderPoolMockRecorder is the mock recorder for MockTagDecoderPool.

func (*MockTagDecoderPoolMockRecorder) Get

Get indicates an expected call of Get.

func (*MockTagDecoderPoolMockRecorder) Init

Init indicates an expected call of Init.

func (*MockTagDecoderPoolMockRecorder) Put

func (mr *MockTagDecoderPoolMockRecorder) Put(arg0 interface{}) *gomock.Call

Put indicates an expected call of Put.

type MockTagEncoder

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

MockTagEncoder is a mock of TagEncoder interface.

func NewMockTagEncoder

func NewMockTagEncoder(ctrl *gomock.Controller) *MockTagEncoder

NewMockTagEncoder creates a new mock instance.

func (*MockTagEncoder) Data

func (m *MockTagEncoder) Data() (checked.Bytes, bool)

Data mocks base method.

func (*MockTagEncoder) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTagEncoder) Encode

func (m *MockTagEncoder) Encode(arg0 ident.TagIterator) error

Encode mocks base method.

func (*MockTagEncoder) Finalize

func (m *MockTagEncoder) Finalize()

Finalize mocks base method.

func (*MockTagEncoder) Reset

func (m *MockTagEncoder) Reset()

Reset mocks base method.

type MockTagEncoderMockRecorder

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

MockTagEncoderMockRecorder is the mock recorder for MockTagEncoder.

func (*MockTagEncoderMockRecorder) Data

Data indicates an expected call of Data.

func (*MockTagEncoderMockRecorder) Encode

func (mr *MockTagEncoderMockRecorder) Encode(arg0 interface{}) *gomock.Call

Encode indicates an expected call of Encode.

func (*MockTagEncoderMockRecorder) Finalize

func (mr *MockTagEncoderMockRecorder) Finalize() *gomock.Call

Finalize indicates an expected call of Finalize.

func (*MockTagEncoderMockRecorder) Reset

func (mr *MockTagEncoderMockRecorder) Reset() *gomock.Call

Reset indicates an expected call of Reset.

type MockTagEncoderPool

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

MockTagEncoderPool is a mock of TagEncoderPool interface.

func NewMockTagEncoderPool

func NewMockTagEncoderPool(ctrl *gomock.Controller) *MockTagEncoderPool

NewMockTagEncoderPool creates a new mock instance.

func (*MockTagEncoderPool) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTagEncoderPool) Get

func (m *MockTagEncoderPool) Get() TagEncoder

Get mocks base method.

func (*MockTagEncoderPool) Init

func (m *MockTagEncoderPool) Init()

Init mocks base method.

func (*MockTagEncoderPool) Put

func (m *MockTagEncoderPool) Put(arg0 TagEncoder)

Put mocks base method.

type MockTagEncoderPoolMockRecorder

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

MockTagEncoderPoolMockRecorder is the mock recorder for MockTagEncoderPool.

func (*MockTagEncoderPoolMockRecorder) Get

Get indicates an expected call of Get.

func (*MockTagEncoderPoolMockRecorder) Init

Init indicates an expected call of Init.

func (*MockTagEncoderPoolMockRecorder) Put

func (mr *MockTagEncoderPoolMockRecorder) Put(arg0 interface{}) *gomock.Call

Put indicates an expected call of Put.

type TagDecoder

type TagDecoder interface {
	ident.TagIterator

	// Reset resets internal state to iterate over the provided bytes.
	// NB: the TagDecoder takes ownership of the provided checked.Bytes.
	Reset(checked.Bytes)
}

TagDecoder decodes an encoded byte stream to a TagIterator.

type TagDecoderOptions

type TagDecoderOptions interface {
	// SetCheckedBytesWrapperPool sets the checked.Bytes wrapper pool.
	SetCheckedBytesWrapperPool(v xpool.CheckedBytesWrapperPool) TagDecoderOptions

	// CheckedBytesWrapperPool returns the checked.Bytes wrapper pool.
	CheckedBytesWrapperPool() xpool.CheckedBytesWrapperPool

	// SetTagSerializationLimits sets the TagSerializationLimits.
	SetTagSerializationLimits(v TagSerializationLimits) TagDecoderOptions

	// TagSerializationLimits returns the TagSerializationLimits.
	TagSerializationLimits() TagSerializationLimits
}

TagDecoderOptions sets the knobs for TagDecoders.

func NewTagDecoderOptions

func NewTagDecoderOptions(cfg TagDecoderOptionsConfig) TagDecoderOptions

NewTagDecoderOptions returns a new TagDecoderOptions.

type TagDecoderOptionsConfig added in v0.15.0

type TagDecoderOptionsConfig struct {
	CheckBytesWrapperPoolSize          *int     `yaml:"checkBytesWrapperPoolSize"`
	CheckBytesWrapperPoolLowWatermark  *float64 `yaml:"checkBytesWrapperPoolLowWatermark"`
	CheckBytesWrapperPoolHighWatermark *float64 `yaml:"checkBytesWrapperPoolHighWatermark"`
}

TagDecoderOptionsConfig allows for defaults to be set at initialization.

func (TagDecoderOptionsConfig) CheckBytesWrapperPoolHighWatermarkOrDefault added in v0.15.0

func (c TagDecoderOptionsConfig) CheckBytesWrapperPoolHighWatermarkOrDefault() float64

CheckBytesWrapperPoolHighWatermarkOrDefault returns config value or default.

func (TagDecoderOptionsConfig) CheckBytesWrapperPoolLowWatermarkOrDefault added in v0.15.0

func (c TagDecoderOptionsConfig) CheckBytesWrapperPoolLowWatermarkOrDefault() float64

CheckBytesWrapperPoolLowWatermarkOrDefault returns config value or default.

func (TagDecoderOptionsConfig) CheckBytesWrapperPoolSizeOrDefault added in v0.15.0

func (c TagDecoderOptionsConfig) CheckBytesWrapperPoolSizeOrDefault() int

CheckBytesWrapperPoolSizeOrDefault returns config value or default.

type TagDecoderPool

type TagDecoderPool interface {
	// Init initializes the pool.
	Init()

	// Get returns a decoder. NB: calling Finalize() on the
	// returned TagDecoder puts it back in the pool.
	Get() TagDecoder

	// Put puts the decoder back in the pool.
	Put(TagDecoder)
}

TagDecoderPool pools TagDecoders.

func NewTagDecoderPool

func NewTagDecoderPool(
	dopts TagDecoderOptions,
	opts pool.ObjectPoolOptions,
) TagDecoderPool

NewTagDecoderPool returns a new TagDecoderPool.

type TagEncoder

type TagEncoder interface {
	// Encode encodes the provided iterator into its internal byte stream.
	// NB: leaves the original iterator un-modified.
	Encode(ident.TagIterator) error

	// Data returns the encoded bytes.
	// NB: The bytes returned as still owned by the TagEncoder. i.e. They are
	// only safe for use until Reset/Finalize is called upon the original
	// TagEncoder.
	Data() (checked.Bytes, bool)

	// Reset resets the internal state to allow reuse of the encoder.
	Reset()

	// Finalize releases any held resources.
	Finalize()
}

TagEncoder encodes provided Tag iterators.

type TagEncoderOptions

type TagEncoderOptions interface {
	// SetInitialCapacity sets the initial capacity of the bytes underlying
	// the TagEncoder.
	SetInitialCapacity(v int) TagEncoderOptions

	// InitialCapacity returns the initial capacity of the bytes underlying
	// the TagEncoder.
	InitialCapacity() int

	// SetTagSerializationLimits sets the TagSerializationLimits.
	SetTagSerializationLimits(v TagSerializationLimits) TagEncoderOptions

	// TagSerializationLimits returns the TagSerializationLimits.
	TagSerializationLimits() TagSerializationLimits
}

TagEncoderOptions sets the knobs for TagEncoder limits.

func NewTagEncoderOptions

func NewTagEncoderOptions() TagEncoderOptions

NewTagEncoderOptions returns a new TagEncoderOptions.

type TagEncoderPool

type TagEncoderPool interface {
	// Init initializes the pool.
	Init()

	// Get returns an encoder. NB: calling Finalize() on the
	// returned TagEncoder puts it back in the pool.
	Get() TagEncoder

	// Put puts the encoder back in the pool.
	Put(TagEncoder)
}

TagEncoderPool pools TagEncoders.

func NewTagEncoderPool

func NewTagEncoderPool(topts TagEncoderOptions, opts pool.ObjectPoolOptions) TagEncoderPool

NewTagEncoderPool returns a new TagEncoderPool.

type TagSerializationLimits

type TagSerializationLimits interface {
	// SetMaxNumberTags sets the maximum number of tags allowed.
	SetMaxNumberTags(uint16) TagSerializationLimits

	// MaxNumberTags returns the maximum number of tags allowed.
	MaxNumberTags() uint16

	// SetMaxTagLiteralLength sets the maximum length of a tag Name/Value.
	SetMaxTagLiteralLength(uint16) TagSerializationLimits

	// MaxTagLiteralLength returns the maximum length of a tag Name/Value.
	MaxTagLiteralLength() uint16
}

TagSerializationLimits sets the limits around tag serialization.

func NewTagSerializationLimits

func NewTagSerializationLimits() TagSerializationLimits

NewTagSerializationLimits returns a new TagSerializationLimits object.

Jump to

Keyboard shortcuts

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