protoparserutil

package
v1.110.28 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: Apache-2.0 Imports: 22 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetExtraLabels

func GetExtraLabels(req *http.Request) ([]prompb.Label, error)

GetExtraLabels extracts name:value labels from `extra_label=name=value` query args from req.

It also extracts Pushgateways-compatible extra labels from req.URL.Path according to https://github.com/prometheus/pushgateway#url .

func GetTimestamp

func GetTimestamp(req *http.Request) (int64, error)

GetTimestamp extracts unix timestamp in milliseconds from `timestamp` query arg.

It returns 0 if there is no `timestamp` query arg.

func GetUncompressedReader

func GetUncompressedReader(r io.Reader, contentType string) (io.Reader, error)

GetUncompressedReader returns uncompressed reader for r and the given contentType

The returned reader must be passed to PutUncompressedReader when no longer needed.

func HandleVMProtoServerHandshake deprecated

func HandleVMProtoServerHandshake(w http.ResponseWriter, r *http.Request) bool

HandleVMProtoServerHandshake returns true if r contains handshake request for determining the supported protocol version.

Deprecated: New vmagent versions skip the handshake and use the VictoriaMetrics remote write protocol by default. See: https://github.com/VictoriaMetrics/VictoriaMetrics/pull/8462

func PutUncompressedReader

func PutUncompressedReader(r io.Reader)

PutUncompressedReader puts r to the pool, so it could be reused via GetUncompressedReader()

func ReadLinesBlock

func ReadLinesBlock(r io.Reader, dstBuf, tailBuf []byte) ([]byte, []byte, error)

ReadLinesBlock reads a block of lines delimited by '\n' from tailBuf and r into dstBuf.

Trailing chars after the last newline are put into tailBuf.

Returns (dstBuf, tailBuf).

It is expected that read timeout on r exceeds 1 second.

func ReadLinesBlockExt

func ReadLinesBlockExt(r io.Reader, dstBuf, tailBuf []byte, maxLineLen int) ([]byte, []byte, error)

ReadLinesBlockExt reads a block of lines delimited by '\n' from tailBuf and r into dstBuf.

Trailing chars after the last newline are put into tailBuf.

Returns (dstBuf, tailBuf).

maxLineLen limits the maximum length of a single line.

It is expected that read timeout on r exceeds 1 second.

func ReadUncompressedData

func ReadUncompressedData(r io.Reader, contentType string, maxDataSize *flagutil.Bytes, callback func(data []byte) error) error

ReadUncompressedData reads uncompressed data from r using the given encoding and then passes it to the callback.

The maxDataSize limits the maximum data size, which can be read from r.

The callback must not hold references to the data after returning.

func ScheduleUnmarshalWork

func ScheduleUnmarshalWork(uw UnmarshalWork)

ScheduleUnmarshalWork schedules uw to run in the worker pool.

It is expected that StartUnmarshalWorkers is already called.

func StartUnmarshalWorkers

func StartUnmarshalWorkers()

StartUnmarshalWorkers starts unmarshal workers.

func StopUnmarshalWorkers

func StopUnmarshalWorkers()

StopUnmarshalWorkers stops unmarshal workers.

No more calls to ScheduleUnmarshalWork are allowed after calling stopUnmarshalWorkers

Types

type UnmarshalWork

type UnmarshalWork interface {
	// Unmarshal must implement CPU-bound unmarshal work.
	Unmarshal()
}

UnmarshalWork is a unit of unmarshal work.

Jump to

Keyboard shortcuts

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