utils

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEphemeralOrFileClosed added in v1.2.0

func IsEphemeralOrFileClosed(err error) bool

IsEphemeralOrFileClosed checks if the error is an ephemeral error or if the file is already closed. This is useful on certain file systems (e.g. on Windows) where in practice reading a file can result in ephemeral errors (e.g. due to antivirus scans) or if the file appears as closed when being removed or rotated.

func NewRemoteWriteServer

func NewRemoteWriteServer(receivedChan chan RemoteWriteRequest, status int) *httptest.Server

NewRemoteWriteServer creates and starts a new httpserver.Server that can handle remote write request. When a request is handled, the received entries are written to receivedChan, and status is responded.

func ToLabelSet

func ToLabelSet(in map[string]string) model.LabelSet

ToLabelSet converts a map of strings to a prometheus LabelSet.

Types

type RemoteWriteRequest

type RemoteWriteRequest struct {
	TenantID string
	Request  logproto.PushRequest
}

RemoteWriteRequest wraps the received logs remote write request that is received.

type SyncSlice

type SyncSlice[T any] struct {
	// contains filtered or unexported fields
}

SyncSlice is a concurrent slice implementation.

func NewSyncSlice

func NewSyncSlice[T any]() *SyncSlice[T]

func (*SyncSlice[T]) Append

func (ss *SyncSlice[T]) Append(el T)

func (*SyncSlice[T]) DoneIterate

func (ss *SyncSlice[T]) DoneIterate()

DoneIterate releases the internal read-lock.

func (*SyncSlice[T]) Length

func (ss *SyncSlice[T]) Length() int

func (*SyncSlice[T]) Reset

func (ss *SyncSlice[T]) Reset()

Reset resets the slice to have zero elements. If used during benchmarks, this will probably make new appends more efficient since the underlying array has more room.

func (*SyncSlice[T]) StartIterate

func (ss *SyncSlice[T]) StartIterate() []T

StartIterate returns the internal slice, after read-locking the internal lock. Once the iteration is finished, DoneIterate should be called to release the lock.

Jump to

Keyboard shortcuts

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