common

package
v1.97.8 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 16 Imported by: 31

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetExtraLabels added in v1.40.1

func GetExtraLabels(req *http.Request) ([]prompbmarshal.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 GetGzipReader

func GetGzipReader(r io.Reader) (*gzip.Reader, error)

GetGzipReader returns new gzip reader from the pool.

Return back the gzip reader when it no longer needed with PutGzipReader.

func GetTimestamp added in v1.41.0

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 GetZlibReader added in v1.67.0

func GetZlibReader(r io.Reader) (io.ReadCloser, error)

GetZlibReader returns zlib reader.

func HandleVMProtoClientHandshake added in v1.88.0

func HandleVMProtoClientHandshake(remoteWriteURL string, doRequest func(handshakeURL string) (*http.Response, error)) bool

HandleVMProtoClientHandshake returns true if the server at remoteWriteURL supports VictoriaMetrics remote write protocol.

func HandleVMProtoServerHandshake added in v1.88.0

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

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

func PutGzipReader

func PutGzipReader(zr *gzip.Reader)

PutGzipReader returns back gzip reader obtained via GetGzipReader.

func PutZlibReader added in v1.67.0

func PutZlibReader(zr io.ReadCloser)

PutZlibReader returns back zlib reader obtained via GetZlibReader.

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 ScheduleUnmarshalWork added in v1.42.0

func ScheduleUnmarshalWork(uw UnmarshalWork)

ScheduleUnmarshalWork schedules uw to run in the worker pool.

It is expected that StartUnmarshalWorkers is already called.

func StartUnmarshalWorkers added in v1.42.0

func StartUnmarshalWorkers()

StartUnmarshalWorkers starts unmarshal workers.

func StopUnmarshalWorkers added in v1.42.0

func StopUnmarshalWorkers()

StopUnmarshalWorkers stops unmarshal workers.

No more calls to ScheduleUnmarshalWork are allowed after calling stopUnmarshalWorkers

Types

type UnmarshalWork added in v1.42.0

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