MCPcopy
hub / github.com/prometheus/client_golang / compressPayload

Function compressPayload

exp/api/remote/remote_api.go:282–296  ·  view source on GitHub ↗
(tmpbuf *[]byte, enc Compression, inp []byte)

Source from the content-addressed store, hash-verified

280}
281
282func compressPayload(tmpbuf *[]byte, enc Compression, inp []byte) (compressed []byte, _ error) {
283 switch enc {
284 case SnappyBlockCompression:
285 if cap(*tmpbuf) < snappy.MaxEncodedLen(len(inp)) {
286 *tmpbuf = make([]byte, snappy.MaxEncodedLen(len(inp)))
287 } else {
288 *tmpbuf = (*tmpbuf)[:snappy.MaxEncodedLen(len(inp))]
289 }
290
291 compressed = snappy.Encode(*tmpbuf, inp)
292 return compressed, nil
293 default:
294 return compressed, fmt.Errorf("unknown compression scheme [%v]", enc)
295 }
296}
297
298func (r *API) attemptWrite(ctx context.Context, compr Compression, msgType WriteMessageType, payload []byte, attempt int) (WriteResponseStats, error) {
299 req, err := http.NewRequest(http.MethodPost, r.baseURL.String(), bytes.NewReader(payload))

Callers 1

WriteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected