Documentation ¶
Overview ¶
Package codable provides types that implement encoding.BinaryMarshaler and encoding.BinaryUnmarshaler and functions that help to encode and decode primitives. The Prometheus storage backend uses them to persist objects to files and to save objects in LevelDB.
The encodings used in this package are designed in a way that objects can be unmarshaled from a continuous byte stream, i.e. the information when to stop reading is determined by the format. No separate termination information is needed.
Strings are encoded as the length of their bytes as a varint followed by their bytes.
Slices are encoded as their length as a varint followed by their elements.
Maps are encoded as the number of mappings as a varint, followed by the mappings, each of which consists of the key followed by the value.
Index ¶
- func DecodeUint64(r io.Reader) (uint64, error)
- func EncodeUint64(w io.Writer, u uint64) error
- func EncodeUvarint(w io.Writer, i uint64) (int, error)
- func EncodeVarint(w io.Writer, i int64) (int, error)
- type Fingerprint
- type FingerprintSet
- type Fingerprints
- type LabelName
- type LabelPair
- type LabelValueSet
- type LabelValues
- type Metric
- type TimeRange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeUint64 ¶
DecodeUint64 reads an uint64 from an io.Reader in big-endian byte-order. This is a GC-friendly implementation that takes the required staging buffer from a buffer pool.
func EncodeUint64 ¶
EncodeUint64 writes an uint64 to an io.Writer in big-endian byte-order. This is a GC-friendly implementation that takes the required staging buffer from a buffer pool.
func EncodeUvarint ¶
EncodeUvarint encodes an uint64 as a varint and writes it to an io.Writer. It returns the number of bytes written. This is a GC-friendly implementation that takes the required staging buffer from a buffer pool.
Types ¶
type Fingerprint ¶
type Fingerprint model.Fingerprint
A Fingerprint is a model.Fingerprint that implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler. The implementation depends on model.Fingerprint to be convertible to uint64. It encodes the fingerprint as a big-endian uint64.
func (Fingerprint) MarshalBinary ¶
func (fp Fingerprint) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
func (*Fingerprint) UnmarshalBinary ¶
func (fp *Fingerprint) UnmarshalBinary(buf []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type FingerprintSet ¶
type FingerprintSet map[model.Fingerprint]struct{}
FingerprintSet is a map[model.Fingerprint]struct{} that implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler. Its binary form is identical to that of Fingerprints.
func (FingerprintSet) MarshalBinary ¶
func (fps FingerprintSet) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
func (*FingerprintSet) UnmarshalBinary ¶
func (fps *FingerprintSet) UnmarshalBinary(buf []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type Fingerprints ¶
type Fingerprints model.Fingerprints
Fingerprints is a model.Fingerprints that implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler. Its binary form is identical to that of FingerprintSet.
func (Fingerprints) MarshalBinary ¶
func (fps Fingerprints) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
func (*Fingerprints) UnmarshalBinary ¶
func (fps *Fingerprints) UnmarshalBinary(buf []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type LabelName ¶
LabelName is a model.LabelName that implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler.
func (LabelName) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*LabelName) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type LabelPair ¶
LabelPair is a model.LabelPair that implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler.
func (LabelPair) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*LabelPair) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type LabelValueSet ¶
type LabelValueSet map[model.LabelValue]struct{}
LabelValueSet is a map[model.LabelValue]struct{} that implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler. Its binary form is identical to that of LabelValues.
func (LabelValueSet) MarshalBinary ¶
func (vs LabelValueSet) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
func (*LabelValueSet) UnmarshalBinary ¶
func (vs *LabelValueSet) UnmarshalBinary(buf []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type LabelValues ¶
type LabelValues model.LabelValues
LabelValues is a model.LabelValues that implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler. Its binary form is identical to that of LabelValueSet.
func (LabelValues) MarshalBinary ¶
func (vs LabelValues) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
func (*LabelValues) UnmarshalBinary ¶
func (vs *LabelValues) UnmarshalBinary(buf []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type Metric ¶
A Metric is a model.Metric that implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler.
func (Metric) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*Metric) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler. It can be used with the zero value of Metric.
func (*Metric) UnmarshalFromReader ¶
UnmarshalFromReader unmarshals a Metric from a reader that implements both, io.Reader and io.ByteReader. It can be used with the zero value of Metric.
type TimeRange ¶
TimeRange is used to define a time range and implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler.
func (TimeRange) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*TimeRange) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.