ident

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 10 Imported by: 112

Documentation

Overview

Package ident is a generated GoMock package.

Package ident provides utilities for working with identifiers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BytesID

type BytesID []byte

BytesID is a small utility type to avoid the heavy weight of a true ID implementation when using in high throughput places like keys in a map.

func (BytesID) Bytes

func (v BytesID) Bytes() []byte

Bytes returns the underlying byte slice of the bytes ID.

func (BytesID) Equal

func (v BytesID) Equal(value ID) bool

Equal returns whether the bytes ID is equal to a given ID.

func (BytesID) Finalize

func (v BytesID) Finalize()

Finalize is a no-op for a bytes ID as it has no associated pool.

func (BytesID) IsNoFinalize

func (v BytesID) IsNoFinalize() bool

IsNoFinalize is always true since BytesID is not pooled.

func (BytesID) NoFinalize

func (v BytesID) NoFinalize()

NoFinalize is a no-op for a bytes ID as Finalize is already a no-op.

func (BytesID) String

func (v BytesID) String() string

String returns the bytes ID as a string.

type ID

type ID interface {
	fmt.Stringer

	// Bytes returns the underlying byte slice of the bytes ID unpacked from
	// any checked bytes container, callers cannot safely hold a ref to these
	// bytes.
	Bytes() []byte

	// Equal returns whether the ID is equal to a given ID.
	Equal(value ID) bool

	// NoFinalize makes calls to finalize a no-op, this is useful when you
	// would like to share a type with another sub-system that should is not
	// allowed to finalize the resource as the resource is kept indefinitely
	// until garbage collected (i.e. longly lived).
	NoFinalize()

	// IsNoFinalize returns whether finalize is a no-op or not, this is useful
	// when you know you can use an ID without having to worry to take a copy.
	IsNoFinalize() bool

	// Finalize releases all resources held by the ID, unless NoFinalize has
	// been called previously in which case this is a no-op.
	Finalize()
}

ID represents an immutable identifier to allow use of byte slice pooling for the contents of the ID.

func BinaryID

func BinaryID(v checked.Bytes) ID

BinaryID constructs a new ID based on a binary value.

func StringID

func StringID(str string) ID

StringID constructs a new ID based on a string value.

type IDBatch added in v1.0.0

type IDBatch struct {

	// ShardIDs are the ShardIDs for the batch.
	ShardIDs []ShardID
	// contains filtered or unexported fields
}

IDBatch is a batch of ShardIDs that is consumed asynchronously.

func (*IDBatch) Processed added in v1.0.0

func (b *IDBatch) Processed()

Processed indicates that this batch has finished processing.

func (*IDBatch) ReadyForProcessing added in v1.0.0

func (b *IDBatch) ReadyForProcessing()

ReadyForProcessing indicates this batch is ready for processing.

func (*IDBatch) WaitUntilProcessed added in v1.0.0

func (b *IDBatch) WaitUntilProcessed()

WaitUntilProcessed waits until the batch has been processed.

type IDMatcher

type IDMatcher interface {
	gomock.Matcher
}

IDMatcher is a gomock.Matcher that matches ID

func NewIDMatcher

func NewIDMatcher(id string) IDMatcher

NewIDMatcher returns a new IDMatcher

type Iterator

type Iterator interface {
	// Next returns a bool indicating the presence of the next ID instance.
	Next() bool

	// Current returns the current ID instance.
	Current() ID

	// CurrentIndex returns the current index at.
	CurrentIndex() int

	// Close releases any resources held by the iterator.
	Close()

	// Err returns any errors encountered during iteration.
	Err() error

	// Len returns the number of elements.
	Len() int

	// Remaining returns the number of elements remaining to be iterated over.
	Remaining() int

	// Dupe returns an independent duplicate of the iterator.
	Duplicate() Iterator
}

Iterator represents an iterator over `ID` instances. It is not thread-safe.

func NewIDSliceIterator

func NewIDSliceIterator(ids []ID) Iterator

NewIDSliceIterator returns a new Iterator over a slice.

func NewIDsIterator

func NewIDsIterator(ids ...ID) Iterator

NewIDsIterator returns a new Iterator over the given IDs.

func NewStringIDsIterator

func NewStringIDsIterator(ids ...string) Iterator

NewStringIDsIterator returns a new Iterator over the given IDs.

func NewStringIDsSliceIterator

func NewStringIDsSliceIterator(ids []string) Iterator

NewStringIDsSliceIterator returns a new Iterator over a slice of strings.

type MockID

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

MockID is a mock of ID interface

func NewMockID

func NewMockID(ctrl *gomock.Controller) *MockID

NewMockID creates a new mock instance

func (*MockID) Bytes

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

Bytes mocks base method

func (*MockID) EXPECT

func (m *MockID) EXPECT() *MockIDMockRecorder

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

func (*MockID) Equal

func (m *MockID) Equal(arg0 ID) bool

Equal mocks base method

func (*MockID) Finalize

func (m *MockID) Finalize()

Finalize mocks base method

func (*MockID) IsNoFinalize

func (m *MockID) IsNoFinalize() bool

IsNoFinalize mocks base method

func (*MockID) NoFinalize

func (m *MockID) NoFinalize()

NoFinalize mocks base method

func (*MockID) String

func (m *MockID) String() string

String mocks base method

type MockIDMockRecorder

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

MockIDMockRecorder is the mock recorder for MockID

func (*MockIDMockRecorder) Bytes

func (mr *MockIDMockRecorder) Bytes() *gomock.Call

Bytes indicates an expected call of Bytes

func (*MockIDMockRecorder) Equal

func (mr *MockIDMockRecorder) Equal(arg0 interface{}) *gomock.Call

Equal indicates an expected call of Equal

func (*MockIDMockRecorder) Finalize

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

Finalize indicates an expected call of Finalize

func (*MockIDMockRecorder) IsNoFinalize

func (mr *MockIDMockRecorder) IsNoFinalize() *gomock.Call

IsNoFinalize indicates an expected call of IsNoFinalize

func (*MockIDMockRecorder) NoFinalize

func (mr *MockIDMockRecorder) NoFinalize() *gomock.Call

NoFinalize indicates an expected call of NoFinalize

func (*MockIDMockRecorder) String

func (mr *MockIDMockRecorder) String() *gomock.Call

String indicates an expected call of String

type MockTagIterator

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

MockTagIterator is a mock of TagIterator interface

func NewMockTagIterator

func NewMockTagIterator(ctrl *gomock.Controller) *MockTagIterator

NewMockTagIterator creates a new mock instance

func (*MockTagIterator) Close

func (m *MockTagIterator) Close()

Close mocks base method

func (*MockTagIterator) Current

func (m *MockTagIterator) Current() Tag

Current mocks base method

func (*MockTagIterator) CurrentIndex

func (m *MockTagIterator) CurrentIndex() int

CurrentIndex mocks base method

func (*MockTagIterator) Duplicate

func (m *MockTagIterator) Duplicate() TagIterator

Duplicate mocks base method

func (*MockTagIterator) EXPECT

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

func (*MockTagIterator) Err

func (m *MockTagIterator) Err() error

Err mocks base method

func (*MockTagIterator) Len

func (m *MockTagIterator) Len() int

Len mocks base method

func (*MockTagIterator) Next

func (m *MockTagIterator) Next() bool

Next mocks base method

func (*MockTagIterator) Remaining

func (m *MockTagIterator) Remaining() int

Remaining mocks base method

func (*MockTagIterator) Rewind added in v0.15.2

func (m *MockTagIterator) Rewind()

Rewind mocks base method

type MockTagIteratorMockRecorder

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

MockTagIteratorMockRecorder is the mock recorder for MockTagIterator

func (*MockTagIteratorMockRecorder) Close

Close indicates an expected call of Close

func (*MockTagIteratorMockRecorder) Current

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

Current indicates an expected call of Current

func (*MockTagIteratorMockRecorder) CurrentIndex

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

CurrentIndex indicates an expected call of CurrentIndex

func (*MockTagIteratorMockRecorder) Duplicate

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

Duplicate indicates an expected call of Duplicate

func (*MockTagIteratorMockRecorder) Err

Err indicates an expected call of Err

func (*MockTagIteratorMockRecorder) Len

Len indicates an expected call of Len

func (*MockTagIteratorMockRecorder) Next

Next indicates an expected call of Next

func (*MockTagIteratorMockRecorder) Remaining

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

Remaining indicates an expected call of Remaining

func (*MockTagIteratorMockRecorder) Rewind added in v0.15.2

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

Rewind indicates an expected call of Rewind

type Pool

type Pool interface {
	// GetBinaryID will create a new binary ID and take reference to the bytes.
	// When the context closes the ID will be finalized and so too will
	// the bytes, i.e. it will take ownership of the bytes.
	GetBinaryID(c context.Context, data checked.Bytes) ID

	// BinaryID will create a new binary ID and take a reference to the bytes.
	BinaryID(data checked.Bytes) ID

	// GetBinaryTag will create a new binary Tag and take reference to the bytes.
	// When the context closes, the Tag will be finalized and so too will
	// the bytes, i.e. it will take ownership of the bytes.
	GetBinaryTag(c context.Context, name, value checked.Bytes) Tag

	// BinaryTag will create a new binary Tag and take a reference to the provided bytes.
	BinaryTag(name, value checked.Bytes) Tag

	// GetStringID will create a new string ID and create a bytes copy of the
	// string. When the context closes the ID will be finalized.
	GetStringID(c context.Context, id string) ID

	// StringID will create a new string ID and create a bytes copy of the
	// string.
	StringID(data string) ID

	// GetStringTag will create a new string Tag and create a bytes copy of the
	// string. When the context closes the ID will be finalized.
	GetStringTag(c context.Context, name, value string) Tag

	// StringTag will create a new string Tag and create a bytes copy of the
	// string.
	StringTag(name, value string) Tag

	// Tags will create a new array of tags and return it.
	Tags() Tags

	// GetTagsIterator will create a tag iterator and return it. When the context
	// closes the tags array and any tags contained will be finalized.
	GetTagsIterator(c context.Context) TagsIterator

	// TagsIterator will create a tag iterator and return it.
	TagsIterator() TagsIterator

	// Put an ID back in the pool.
	Put(id ID)

	// PutTag puts a tag back in the pool.
	PutTag(tag Tag)

	// PutTags puts a set of tags back in the pool.
	PutTags(tags Tags)

	// PutTagsIterator puts a tags iterator back in the pool.
	PutTagsIterator(iter TagsIterator)

	// Clone replicates a given ID into a pooled ID.
	Clone(id ID) ID

	// CloneTag replicates a given Tag into a pooled Tag.
	CloneTag(tag Tag) Tag

	// CloneTags replicates a given set of Tags into a pooled Tags.
	CloneTags(tags Tags) Tags
}

Pool represents an automatic pool of `ident` objects.

func NewPool

func NewPool(
	bytesPool pool.CheckedBytesPool,
	opts PoolOptions,
) Pool

NewPool constructs a new simple Pool.

type PoolOptions

type PoolOptions struct {
	IDPoolOptions           pool.ObjectPoolOptions
	TagsPoolOptions         pool.ObjectPoolOptions
	TagsCapacity            int
	TagsMaxCapacity         int
	TagsIteratorPoolOptions pool.ObjectPoolOptions
}

PoolOptions is a set of pooling options.

type ReusableBytesID added in v1.0.1

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

ReusableBytesID is a reusable bytes ID, use with extreme care in places where the lifecycle is known (there is no checking with this ID).

func NewReusableBytesID added in v1.0.1

func NewReusableBytesID() *ReusableBytesID

NewReusableBytesID returns a new reusable bytes ID, use with extreme care in places where the lifecycle is known (there is no checking with this ID).

func (*ReusableBytesID) Bytes added in v1.0.1

func (i *ReusableBytesID) Bytes() []byte

Bytes implements ID.

func (*ReusableBytesID) Equal added in v1.0.1

func (i *ReusableBytesID) Equal(value ID) bool

Equal implements ID.

func (*ReusableBytesID) Finalize added in v1.0.1

func (i *ReusableBytesID) Finalize()

Finalize implements ID.

func (*ReusableBytesID) IsNoFinalize added in v1.0.1

func (i *ReusableBytesID) IsNoFinalize() bool

IsNoFinalize implements ID.

func (*ReusableBytesID) NoFinalize added in v1.0.1

func (i *ReusableBytesID) NoFinalize()

NoFinalize implements ID.

func (*ReusableBytesID) Reset added in v1.0.1

func (i *ReusableBytesID) Reset(bytes []byte)

Reset resets the bytes ID for reuse, make sure there are zero references to this ID from any other data structure at this point.

func (*ReusableBytesID) String added in v1.0.1

func (i *ReusableBytesID) String() string

String returns the bytes ID as a string.

type ShardID added in v1.0.1

type ShardID struct {
	// Shard is the shard the series belongs to.
	Shard uint32
	// ID is the series ID.
	ID ID
}

ShardID is a tuple of series ID and the shard it belongs to.

type Tag

type Tag struct {
	Name  TagName
	Value TagValue
	// contains filtered or unexported fields
}

Tag represents a timeseries tag.

func BinaryTag

func BinaryTag(name checked.Bytes, value checked.Bytes) Tag

BinaryTag constructs a new Tag based on binary values.

func StringTag

func StringTag(name string, value string) Tag

StringTag constructs a new Tag based on string values.

func (Tag) Equal

func (t Tag) Equal(value Tag) bool

Equal returns whether the two tags are equal.

func (*Tag) Finalize

func (t *Tag) Finalize()

Finalize releases all resources held by the Tag, unless NoFinalize has been called previously in which case this is a no-op.

func (*Tag) NoFinalize

func (t *Tag) NoFinalize()

NoFinalize makes calls to finalize a no-op, this is useful when you would like to share a type with another sub-system that should is not allowed to finalize the resource as the resource is kept indefinitely until garbage collected (i.e. longly lived).

type TagIterMatcher

type TagIterMatcher interface {
	gomock.Matcher
}

TagIterMatcher is a gomock.Matcher that matches TagIterator

func NewTagIterMatcher

func NewTagIterMatcher(iter TagIterator) TagIterMatcher

NewTagIterMatcher returns a new TagIterMatcher

type TagIterator

type TagIterator interface {
	// Next returns a bool indicating the presence of the next Tag instance.
	Next() bool

	// Current returns the current Tag instance.
	Current() Tag

	// CurrentIndex returns the current index at.
	CurrentIndex() int

	// Err returns any errors encountered during iteration.
	Err() error

	// Close releases any resources held by the iterator.
	Close()

	// Len returns the number of elements.
	Len() int

	// Remaining returns the number of elements remaining to be iterated over.
	Remaining() int

	// Duplicate returns an independent duplicate of the iterator.
	Duplicate() TagIterator

	// Rewind resets the tag iterator to the initial position.
	Rewind()
}

TagIterator represents an iterator over `Tag` instances. It is not thread-safe.

var EmptyTagIterator TagIterator = emptyTagIterator{}

EmptyTagIterator returns an iterator over no tags.

func MustNewTagStringsIterator

func MustNewTagStringsIterator(inputs ...string) TagIterator

MustNewTagStringsIterator returns a TagIterator over a slice of strings, panic'ing if it encounters an error.

func NewTagStringsIterator

func NewTagStringsIterator(inputs ...string) (TagIterator, error)

NewTagStringsIterator returns a TagIterator over a slice of strings.

type TagMatcher

type TagMatcher interface {
	gomock.Matcher
}

TagMatcher is a gomock.Matcher that matches Tag

func NewTagMatcher

func NewTagMatcher(name string, value string) TagMatcher

NewTagMatcher returns a new TagMatcher

type TagName

type TagName ID

TagName represents the name of a timeseries tag.

type TagValue

type TagValue ID

TagValue represents the value of a timeseries tag.

type Tags

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

Tags is a collection of Tag instances that can be pooled.

func NewTags

func NewTags(values ...Tag) Tags

NewTags returns a new set of tags.

func (*Tags) Append

func (t *Tags) Append(tag Tag)

Append will append a tag.

func (Tags) Equal

func (t Tags) Equal(other Tags) bool

Equal returns a bool indicating if the tags are equal. It requires the two slices are ordered the same.

func (*Tags) Finalize

func (t *Tags) Finalize()

Finalize finalizes all Tags, unless NoFinalize has been called previously in which case this is a no-op.

func (*Tags) NoFinalize

func (t *Tags) NoFinalize()

NoFinalize makes calls to finalize a no-op, this is useful when you would like to share a type with another sub-system that should is not allowed to finalize the resource as the resource is kept indefinitely until garbage collected (i.e. longly lived).

func (*Tags) Reset added in v0.15.0

func (t *Tags) Reset(values []Tag)

Reset resets the tags for reuse.

func (Tags) Values

func (t Tags) Values() []Tag

Values returns the tags values.

type TagsIterator

type TagsIterator interface {
	TagIterator

	// Reset allows the tag iterator to be reused with a new set of tags.
	Reset(tags Tags)

	// ResetFields allows tag iterator to be reused from a set of fields.
	ResetFields(fields []doc.Field)
}

TagsIterator represents a TagIterator that can be reset with a Tags collection type. It is not thread-safe.

func NewFieldsTagsIterator added in v0.15.4

func NewFieldsTagsIterator(fields []doc.Field) TagsIterator

NewFieldsTagsIterator returns a TagsIterator over a set of fields.

func NewTagsIterator

func NewTagsIterator(tags Tags) TagsIterator

NewTagsIterator returns a TagsIterator over a set of tags.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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