labelpb

package
v0.26.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthTypes        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTypes          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group")
)

Functions

func ExtendSortedLabels

func ExtendSortedLabels(lset, extend labels.Labels) labels.Labels

ExtendSortedLabels extend given labels by extend in labels format. The type conversion is done safely, which means we don't modify extend labels underlying array.

In case of existing labels already present in given label set, it will be overwritten by external one. NOTE: Labels and extend has to be sorted.

func HashWithPrefix

func HashWithPrefix(prefix string, lbls []ZLabel) uint64

HashWithPrefix returns a hash for the given prefix and labels.

func LabelsToPromLabels

func LabelsToPromLabels(lset []Label) labels.Labels

LabelsToPromLabels convert slice of labelpb.ZLabel to Prometheus labels in type unsafe manner. It reuses the same memory. Caller should abort using passed []Label.

func PromLabelSetsToString

func PromLabelSetsToString(lsets []labels.Labels) string

func ReAllocZLabelsStrings

func ReAllocZLabelsStrings(lset *[]ZLabel)

ReAllocZLabelsStrings re-allocates all underlying bytes for string, detaching it from bigger memory pool.

func ZLabelSetsToPromLabelSets

func ZLabelSetsToPromLabelSets(lss ...ZLabelSet) []labels.Labels

ZLabelSetsToPromLabelSets converts slice of labelpb.ZLabelSet to slice of Prometheus labels.

func ZLabelsToPromLabels

func ZLabelsToPromLabels(lset []ZLabel) labels.Labels

ZLabelsToPromLabels convert slice of labelpb.ZLabel to Prometheus labels in type unsafe manner. It reuses the same memory. Caller should abort using passed []ZLabel. NOTE: Use with care. ZLabels holds memory from the whole protobuf unmarshal, so the returned Prometheus Labels will hold this memory as well.

Types

type Label

type Label struct {
	Name  string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
}

func LabelsFromPromLabels

func LabelsFromPromLabels(lset labels.Labels) []Label

LabelsFromPromLabels converts Prometheus labels to slice of labelpb.ZLabel in type unsafe manner. It reuses the same memory. Caller should abort using passed labels.Labels.

func (*Label) Descriptor

func (*Label) Descriptor() ([]byte, []int)

func (*Label) Marshal

func (m *Label) Marshal() (dAtA []byte, err error)

func (*Label) MarshalTo

func (m *Label) MarshalTo(dAtA []byte) (int, error)

func (*Label) MarshalToSizedBuffer

func (m *Label) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Label) ProtoMessage

func (*Label) ProtoMessage()

func (*Label) Reset

func (m *Label) Reset()

func (*Label) Size

func (m *Label) Size() (n int)

func (*Label) String

func (m *Label) String() string

func (*Label) Unmarshal

func (m *Label) Unmarshal(dAtA []byte) error

func (*Label) XXX_DiscardUnknown

func (m *Label) XXX_DiscardUnknown()

func (*Label) XXX_Marshal

func (m *Label) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Label) XXX_Merge

func (m *Label) XXX_Merge(src proto.Message)

func (*Label) XXX_Size

func (m *Label) XXX_Size() int

func (*Label) XXX_Unmarshal

func (m *Label) XXX_Unmarshal(b []byte) error

type LabelSet

type LabelSet struct {
	Labels []Label `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels"`
}

func (*LabelSet) Descriptor

func (*LabelSet) Descriptor() ([]byte, []int)

func (*LabelSet) Marshal

func (m *LabelSet) Marshal() (dAtA []byte, err error)

func (*LabelSet) MarshalTo

func (m *LabelSet) MarshalTo(dAtA []byte) (int, error)

func (*LabelSet) MarshalToSizedBuffer

func (m *LabelSet) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*LabelSet) ProtoMessage

func (*LabelSet) ProtoMessage()

func (*LabelSet) Reset

func (m *LabelSet) Reset()

func (*LabelSet) Size

func (m *LabelSet) Size() (n int)

func (*LabelSet) String

func (m *LabelSet) String() string

func (*LabelSet) Unmarshal

func (m *LabelSet) Unmarshal(dAtA []byte) error

func (*LabelSet) XXX_DiscardUnknown

func (m *LabelSet) XXX_DiscardUnknown()

func (*LabelSet) XXX_Marshal

func (m *LabelSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LabelSet) XXX_Merge

func (m *LabelSet) XXX_Merge(src proto.Message)

func (*LabelSet) XXX_Size

func (m *LabelSet) XXX_Size() int

func (*LabelSet) XXX_Unmarshal

func (m *LabelSet) XXX_Unmarshal(b []byte) error

type ZLabel

type ZLabel Label

ZLabel is a Label (also easily transformable to Prometheus labels.Labels) that can be unmarshalled from protobuf reusing the same memory address for string bytes. NOTE: While unmarshalling it uses exactly same bytes that were allocated for protobuf. This mean that *whole* protobuf bytes will be not GC-ed as long as ZLabels are referenced somewhere. Use it carefully, only for short living protobuf message processing.

func DeepCopy

func DeepCopy(lbls []ZLabel) []ZLabel

DeepCopy copies labels and each label's string to separate bytes.

func ZLabelsFromPromLabels

func ZLabelsFromPromLabels(lset labels.Labels) []ZLabel

ZLabelsFromPromLabels converts Prometheus labels to slice of labelpb.ZLabel in type unsafe manner. It reuses the same memory. Caller should abort using passed labels.Labels.

func (*ZLabel) Compare

func (m *ZLabel) Compare(other ZLabel) int

Compare implements proto.Comparer.

func (*ZLabel) Equal

func (m *ZLabel) Equal(other ZLabel) bool

Equal implements proto.Equaler.

func (*ZLabel) Marshal

func (m *ZLabel) Marshal() ([]byte, error)

func (*ZLabel) MarshalJSON

func (m *ZLabel) MarshalJSON() ([]byte, error)

func (*ZLabel) MarshalTo

func (m *ZLabel) MarshalTo(data []byte) (int, error)

func (*ZLabel) MarshalToSizedBuffer

func (m *ZLabel) MarshalToSizedBuffer(data []byte) (int, error)

func (*ZLabel) Size

func (m *ZLabel) Size() (n int)

Size implements proto.Sizer.

func (*ZLabel) Unmarshal

func (m *ZLabel) Unmarshal(data []byte) error

Unmarshal unmarshalls gRPC protobuf into ZLabel struct. ZLabel string is directly using bytes passed in `data`. To use it add (gogoproto.customtype) = "github.com/thanos-io/thanos/pkg/store/labelpb.ZLabel" to proto field tag. NOTE: This exists in internal Google protobuf implementation, but not in open source one: https://news.ycombinator.com/item?id=23588882

func (*ZLabel) UnmarshalJSON

func (m *ZLabel) UnmarshalJSON(entry []byte) error

type ZLabelSet

type ZLabelSet struct {
	Labels []ZLabel `protobuf:"bytes,1,rep,name=labels,proto3,customtype=ZLabel" json:"labels"`
}

func (*ZLabelSet) Descriptor

func (*ZLabelSet) Descriptor() ([]byte, []int)

func (*ZLabelSet) Marshal

func (m *ZLabelSet) Marshal() (dAtA []byte, err error)

func (*ZLabelSet) MarshalJSON

func (m *ZLabelSet) MarshalJSON() ([]byte, error)

func (*ZLabelSet) MarshalTo

func (m *ZLabelSet) MarshalTo(dAtA []byte) (int, error)

func (*ZLabelSet) MarshalToSizedBuffer

func (m *ZLabelSet) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ZLabelSet) PromLabels

func (m *ZLabelSet) PromLabels() labels.Labels

PromLabels return Prometheus labels.Labels without extra allocation.

func (*ZLabelSet) ProtoMessage

func (*ZLabelSet) ProtoMessage()

func (*ZLabelSet) Reset

func (m *ZLabelSet) Reset()

func (*ZLabelSet) Size

func (m *ZLabelSet) Size() (n int)

func (*ZLabelSet) String

func (m *ZLabelSet) String() string

func (*ZLabelSet) Unmarshal

func (m *ZLabelSet) Unmarshal(dAtA []byte) error

func (*ZLabelSet) UnmarshalJSON

func (m *ZLabelSet) UnmarshalJSON(entry []byte) error

func (*ZLabelSet) XXX_DiscardUnknown

func (m *ZLabelSet) XXX_DiscardUnknown()

func (*ZLabelSet) XXX_Marshal

func (m *ZLabelSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ZLabelSet) XXX_Merge

func (m *ZLabelSet) XXX_Merge(src proto.Message)

func (*ZLabelSet) XXX_Size

func (m *ZLabelSet) XXX_Size() int

func (*ZLabelSet) XXX_Unmarshal

func (m *ZLabelSet) XXX_Unmarshal(b []byte) error

type ZLabelSets

type ZLabelSets []ZLabelSet

ZLabelSets is a sortable list of ZLabelSet. It assumes the label pairs in each ZLabelSet element are already sorted.

func (ZLabelSets) Len

func (z ZLabelSets) Len() int

func (ZLabelSets) Less

func (z ZLabelSets) Less(i, j int) bool

func (ZLabelSets) Swap

func (z ZLabelSets) Swap(i, j int)

Jump to

Keyboard shortcuts

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